/    Sign up×
Community /Pin to ProfileBookmark

Help please,

I have links on my web site.
I would like to accomplish that visitor would have 2 options based on checkbox:
1)every link would open in its on window
2)or there would be just one window for all links on top of its parent window.

so far I wrote this code but it does not work.
Every time I click checkbox and link, new window opens
but parent window
changes its content too.

function changeProperties(target)
{

for (var i=0; i<=(document.links.length-1); i++){

document.links[i].onclick=function(){

link_href= document.links[i].href.toString( );
winName= this.name.toString( );
if (typeof(this.name) != “object”)
{ winName = window.open(link_href,winName); winName.focus();}

}

}//end function

<A href=”http://www.google.com” name=”newwindow”>google</A>

<FORM name=’targetform’><INPUT TYPE=’checkbox’ NAME=’targetnew’ ONCLICK=’changeProperties(this.checked)’ checked>link option</FORM>

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@crh3675Feb 02.2004 — <i>
</i>&lt;script&gt;


function popWin(id){
var linkObj=document.getElementById(id);
strLoc=linkObj.getAttribute("href");
strTarget=linkObj.getAttribute("target");

<i> </i>var linkWin=window.open(strLoc,strTarget);
<i> </i>linkWin.focus();
}

&lt;/script&gt;

&lt;a href="http://www.nerds.net" target="myWin" id="link01"&gt;The site&lt;/a&gt;

&lt;a href="http://www.msn.com" target="myWin" id="link02"&gt;The site2&lt;/a&gt;

&lt;form method="post"&gt;
&lt;input type="checkbox" onclick="popWin('link01')"&gt;To site&lt;br&gt;
&lt;input type="checkbox" onclick="popWin('link02')"&gt;To site2
&lt;/form&gt;

Copy linkTweet thisAlerts:
@guccorobauthorFeb 02.2004 — Thank you, but I would like to change properties of all my links with just one checkbox.
Copy linkTweet thisAlerts:
@crh3675Feb 02.2004 — What properties do you want to change?
Copy linkTweet thisAlerts:
@guccorobauthorFeb 03.2004 — Thank you, I got it.


I forgot to add return false;
×

Success!

Help @guccorob spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...