Forum Moderators: open
<script>
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+','
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
</script><a title="link opens in a new window" onclick="NewWindow(this.href,'popup','700','234','no');return false;" href="popup-link.html">
and a bit of js code that will link back from the pop-up window to the main window
<a href="javascript:void()" onClick="opener.parent.location.href('/mainwindow.html')">Main</a>
Without resorting to <noscript>, which I know *can* do the job perfectly well, I was wondering whether there is some way I can combine the this.href from the first bit into the opener.parent from the second, so that the href="javascript:void()" can be replaced with the actual URL: href="/mainwindow.html"
I'm not totally clear on what you are aiming for, but you should just be able to do:
<a href="/mainwindow.html" onclick="window.opener.location.href(this.href)">Main</a>
But I don't think you even need to set the href...it shouldn't have changed since the popup opened, should it? If you don't need to set the href, you can do something like:
<a href="/mainwindow.html" onclick="window.opener.focus(); return false;">Main</a>
Which will bring the parent window back into focus above the popup w/o reloading it.
Jordan
I don't want the pop-up window to change. I could easily close this window onclick, but I dont want to have to do that.
The second suggestion doesn't open the link. What I want to do is open a different URL to the one that contains the original link that opened tht pop-up.
Ahh, I see. The first one should do the trick, I just forgot the return false. Doh! :)
<a href="/mainwindow.html" onclick="window.opener.location.href(this.href); return false;">Main</a>
The return false tells the browser to cancel the click event so that the link href doesn't load as the page href in the popup.
Jordan