javascript

hi,
i want to create a script in which if user clicks on any text box area then automatically new url should open.
can anyone knows that code?

thank you .
LVL 10
d4durveshAsked:
Who is Participating?
 
plusone3055Commented:
http://www.pageresource.com/jscript/jwinopen.htm

<FORM>
<INPUT type="button" value="New Window!" onClick="window.open('http://www.pageresource.com/jscript/jex5.htm','mywindow','width=400,height=200')">
</FORM>

can use the same code in a textbox instead of a button
0
 
nap0leonCommented:
In case plusone3055's post wasn't clear... all you need to do is add the onclick atttribute to your textbox:

onclick="window.open('http://www.pageresource.com/jscript/jex5.htm','mywindow','width=400,height=200')"

If you want this to also happen if someone tabs into the field, you may instead want to use "onfocus" rather than "onclick".
0
 
d4durveshAuthor Commented:
hi, i thanx both of you for your kind replay's.

yes it is working when i tried onclick attribute but not when i use onfocus . it shows that firefox is preveting to open a new pop-up box.

any idea why it showing that??
0
 
nap0leonCommented:
Firefox's pop-up blocker is preventing the pop-up because, well, that's what it is supposed to do.

For onfocus - you probably don't want to do that anyway... use a browser that lets the popup work... watch what happens when you click the popup - you'll get two (one for the onfocus and one for the onclick) - watch what happens when you close the last popup... you'll get another popup (because that box/button/etc has now regained focus).
0
 
d4durveshAuthor Commented:
thanx both of you. :-) good day tc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.