By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,248 Members | 1,547 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,248 IT Pros & Developers. It's quick & easy.

window.open - url variable ?

P: n/a
Really can't figure this out, would appreciate some help...

Have a textbox in a form which user types in a url link.

When they click a button I'd like it to open a new window,
and attempt to display the link they've typed in the textbox.

I've got the button calling a javascript with onclick,
but I can't get the window that opens to accept the dynamic url.

The textbox name is txtlink.

var thelink = txtlink.value;
testlinkwindow = window.open();

Is there a way to get the variable as the url parameter of open() ?

The other thing I've tried is setting the location.href of the child window,
but that doesn't work either. :-(

eg
testlinkwindow = window.open();
testlinkwindow.location.href= txtlink.value;

Please can you help ?
R.
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
R45six wrote:
Really can't figure this out, would appreciate some help...

Have a textbox in a form which user types in a url link.

When they click a button I'd like it to open a new window,
and attempt to display the link they've typed in the textbox.

I've got the button calling a javascript with onclick,
but I can't get the window that opens to accept the dynamic url.

The textbox name is txtlink.

var thelink = txtlink.value;
testlinkwindow = window.open();

var thelink = document.forms['formname'].elements['txtlink'].value
window.open (thelink)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2

P: n/a
"R45six" <ne************@SPAMntlworld.com> wrote in message news:<LO*****************@newsfe6-gui.server.ntli.net>...
Really can't figure this out, would appreciate some help...

Have a textbox in a form which user types in a url link.

When they click a button I'd like it to open a new window,
and attempt to display the link they've typed in the textbox.

I've got the button calling a javascript with onclick,
but I can't get the window that opens to accept the dynamic url.

The textbox name is txtlink.

var thelink = txtlink.value;
testlinkwindow = window.open();

Is there a way to get the variable as the url parameter of open() ?


Have you tried actually passing it as the URL parameter? You don't
have any parameters to open() in the posted code.

Have a look here:

http://www.mozilla.org/docs/dom/domr...6.html#1019331
Jul 23 '05 #3

P: n/a
> var thelink = document.forms['formname'].elements['txtlink'].value
window.open (thelink)


Cheers, couldn't get it accept a variable inside the brackets.

I think it was also a problem, not naming the form.

Ended up with this.

var thelink = formname.txtlink.value
window.open("" + thelink)
Jul 23 '05 #4

P: n/a
R45six wrote:
var thelink = document.forms['formname'].elements['txtlink'].value
window.open (thelink)

Cheers, couldn't get it accept a variable inside the brackets.

I think it was also a problem, not naming the form.

Ended up with this.

var thelink = formname.txtlink.value
window.open("" + thelink)

var myVar = "txtlink";
document.forms['formName'].elements[myVar].value;

you have to drop the quotes inside the brackets when using a variable.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.