Forum Moderators: open
<script language="JavaScript" type="text/javascript">
<!--
function popup(popURL,popHeight,popWidth)
{
options="resizable,height="+popHeight+",width="+popWidth;
window.open(popURL, 'newWin', options);
}
//-->
</script>
<a href="http://www.mydomain/page1.htm" onClick="popup(this.href,480,500);return false;" target="newWin">
Click Here
</a>
In this example, the pop-up is page1.htm. If JS is not enabled, it should take them to page2.htm.
Other things I would like it to do are to allow scrolling, show status bar, and hide the URL in the status bar when someone hovers their mouse over the link for the page.
Many thanks!
Ron, JS Dummy
[blue]
<a href="http://www.mydomain/page2.htm"
onClick="popup("http://www.mydomain/page1.htm",480,500);return false;"
target="_blank">[/blue]
..making sure you return false to the href, which you have.
This will result in the status message showing the incorrect URL for those script-enabled - but then you did ask about hiding the status message...
[blue]
<a href="http://www.mydomain/page2.htm"
onClick="popup("http://www.mydomain/page1.htm",480,500);return false;"
target="_blank"[/blue]
[red]onMouseOver="window.status='';return true;"[/red]
[blue]>[/blue]
For scrollbars, and status bar on the new window, we amend your popup function:
[blue]function popup(popURL,popHeight,popWidth)
{
var options="resizable,height="+popHeight+",width="+popWidth
+",scrollbars=1,status=1";
window.open(popURL, 'newWin', options);
}
[/blue]
..and you're done.
function popup(popURL,popHeight,popWidth)
{
var options="resizable,height="+popHeight+",width="+popWidth
+",scrollbars=1,status=1";
[red]var popWin = [/red]window.open(popURL, 'newWin', options);
[red]popWin.status = "Loading, please wait..."[/red]
}
Changing the message once loaded is best done on the popped page itself.
Do you have any scripts running in it?
1) Hide the URL you see in the status bar when the pop-up is loading.
2) Have some sort of idicator that the page is loading. As the content of the page actually comes from another site, it is sort of slow loading . At very slow times or with a slow connection, it looks like a blank page.
You can't affect the new window once it starts to load, as it's outside your domain, but you could temporarily write a page into it which displays your message, then loads the intended URL.
var pageCode = "<p [red]-no line break here-[/red] style='color:blue;'>PageLoading...</p><script>window.location='URL'</script>"
function popup(popURL,popHeight,popWidth)
{
var fullPageCode = pageCode.replace('URL',popURL)
var options="resizable,height="+popHeight+",width="+popWidth
+",scrollbars=1,status=1";
popWin =window.open("", 'newWin', options);
setTimeout("popWin.document.write('"+fullPageCode+"'),500)
}
Have a go at that.
var pageCode = "<p -no line break here-style='color:blue;'>PageLoading...</p><script>window.location='URL'</script>"
function popup(popURL,popHeight,popWidth)
{
var fullPageCode = pageCode.replace('URL',popURL)
var options="resizable,height="+popHeight+",width="+popWidth
+",scrollbars=1,status=1";
popWin =window.open("", 'newWin', options);
setTimeout("popWin.document.write('"+fullPageCode+"'),500)
}
Also, I am not sure what you mean by an "invisible iframe" but any kind of framing I would think would cause the padlock not to display in the browseras the page inside the iframe is SSL. Your script is a good idea if I could get it to work.
'Invisible frame' means including an IFRAME element in your main page, but setting it's CSS display property to "none". Set it's src to the URL of the pop-up page. This way it will load when the main page loads.
When the 'button' is clicked, and the pop-up is opened, the page will load from cache. This should have no effect on the padlock.
As to the script not opening a pop-up, I'm not sure. How are you calling it in the HTML (in the event handler)?
var pageCode = "<p style='color:blue;'>Page Loading...</p>"
pageCode+= "<script>window.location='URL'</script>"function popup(popURL,popHeight,popWidth)
{
var fullPageCode = pageCode.replace('URL',popURL);
var options = "resizable,height="+popHeight+",width="+popWidth
+",scrollbars=1,status=1";
popWin =window.open("", 'newWin', options);
setTimeout("popWin.document.write(\""+fullPageCode+"\")",500);
}
The IFRAME I referred to would simply look like this:
<iframe src = "script_enabled_URL" style="display:none:"></iframe>
Your main page would take longer to load, of course.
<a href="http://www.MySite.com" onClick="popup('https://www.TheOtherSite.com',480,500);return false;" target="newWin">
Thanks!