Forum Moderators: open
<script>
function link1() {
opener.location.href="http://www.widgets.com/redwidget.htm";
self.blur();
}
function link2() {
opener.location.href="http://www.widgets.com/orgwidget.htm";
self.blur();
}
</script>
<a href="widgpopup.htm" onClick="link1()">Red Widgets</a>
<a href="widgpopup.htm" onClick="link2()">Orange Widgets</a>
While this works...(quite well, in fact)...It has its drawbacks, such as clicking any link causing all of the links act as visited links, and i can't just add links onto my table, i have to add new functions for each specific link...while not a big deal, it is time consuming.
So, my question is: I'm new to javascript, and i'm wondering if i can make this any easier or cut out any of the steps to get the same affect: a popup window that loads clicked links into the parent window that generated the popup.
Any help would be appreciated! Thanks!
Rocky
<a href="javascript:link1()">Red Widgets</a>
<a href="javascript:link2()">Orange Widgets</a>
This should solve your visited link issue.
A more efficient way would be:
<a href="redwidget.htm" onclick="javascript:opener.location.href='http://www.widgets.com/redwidget.htm'; return false">Red Widgets</a>
<a href="orgwidget.htm" onclick="javascript:opener.location.href='http://www.widgets.com/orgwidget.htm'; return false">Orange Widgets</a>
There is no need for the seperate functions this way
[edited by: tedster at 4:38 pm (utc) on July 19, 2003]
[edit reason] turn off smile faces in the code [/edit]
<script>
function link1(element) {
self.opener.location.href=element;
self.blur();
}
</script>
<a href="" onClick="link1('http://www.widgets.com/redwidget.htm')">Red Widgets</a>
<a href="" onClick="link2('http://www.widgets.com/orgwidget.htm')">Orange Widgets</a>
...slightly shorter code
cheers,
dr_j