473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

window.open - url variable ?

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
4 13057
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
"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
> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Raptor | last post by:
I'm a complete Javascript n00b, using a snippet I found on the web. I'll probably be buying a Javascript book. What's the authoritative on-line resource for Javascript, like php.net is for PHP? ...
3
by: datactrl | last post by:
Hi, all Is that possible I can assign an window object variable to an already opened window? With window.open(), we can get a window object from opened window. If a window has already opened, is...
2
by: Samir Pandey | last post by:
Hello, I am using the following javascript code to open a new window. Somehow, IE always opens a new window. It doesn't open target url in the window name given. All i want is, if there is a...
8
by: Dominic Tocci | last post by:
I'm searching for a way to use window.open on my web page to open a window in firefox that allows the sidebars to work (bookmarks, history, etc). When I use the following: var...
3
by: Michelle Stone | last post by:
hi al i have "variab1 = window.open ("a.aspx", "helloworld"); i do this inside a RegisterStartupScrict ("key", "<script language=javascript>******</script>"); where ***** is hte javascript...
13
by: tochiromifune | last post by:
Hello The window.open method brings my window to the top only if it is new. If it's being reused, the window does not come to the foreground (with IE 6 it does). Is there a new way in...
2
by: Robert Degen | last post by:
Hello, I got a little problem. Seems very simple: * I want to open a popup window * Popup-window uses data from its father window. BUT a parent.window does NOT point to the real parents...
13
by: Seth Grimes | last post by:
Hello all, I want to open a window when a user leaves my site. I set up a function called by onUnload. To skip the window.open if the user hasn't left my site, I set a variable in my links and...
1
by: Sam | last post by:
Does anyone know if I can write a whole webpage content stored in a variable to a popup window? The variable that I'm talking about is a string variable which has its content generated by an aspx...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.