AllExperts > Experts 
Search      

Javascript

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Javascript Answers
Question Library

Ask a question about Javascript
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Anthony Levensalor
Experience
I have been programming in Java and Javascript since 1998. I run a web development company that specializes in Ajax front ends with PHP/MySQL back ends. I am a Sun Certified Java 2 Developer, and have done nothing but web applications for the last two years in my business

Past/Present clients
Monster.com, Compuware Corporation, Flextronics International, Pragmatech Software, Open Travel Software, The Loss Mitigation Institute, Raw Story Media, Page One News Media.

 
   

You are here:  Experts > Computing/Technology > Focus on JavaScript > Javascript > Radio button with link in new windows

Topic: Javascript



Expert: Anthony Levensalor
Date: 11/29/2007
Subject: Radio button with link in new windows

Question
Dear Anthony,

I would like my radio button to link in a new window, can you tell me how to modify the script?
<input type="radio" name="1" value="1"  onclick="javascript:parent.location.href='mylink';return false;">

Answer
Sure thing. The trouble you're running into here is that the method you're using sets the location of the current window, and there is preciesly no way that I know of to make it open in a new one with window.location.

We are given, however, by the great and wise W3C peeps, a way to open a new window. Looks like this:

window.open("url", null, "options");

Where
url is where you want to go, null doesn't matter, and "options" is one of many different things.

If I wanted to open a new window like you're talking about, I think it sould probably be just like the one we're in now, so I'd call it like this:

<input type="radio" name="blah"
 onclick="window.open(\"myLink\", null, \"\");" />

Check out this article on window.open, I think you will find it extremely useful with your current issue.
http://www.javascript-coder.com/window-popup/javascript-window-open.phtml

~A!

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.