Forum Moderators: open
---js---
<script type="text/javascript">
function newWindow(url) {
var day= new Date();
var id = day.getTime();
var win = open(url,id,'width=560,height=650,scrollbars,resizable');
}
</script>
---HTML---
<a href="rockin/bill.htm" target="_blank" onClick="newWindow('rockin/bill.htm');" return false;>Rockin Bill,</a> javascript<br />
------------------------------
My question is: What is the best way to let the javascript enabled visitors see the page in the popup window without it also opening in a new target page that is meant for the non-javascript users.
Right now it opens in two places for js-enabled visitors and one for the js-disabled visitors.
It's the same page in both instances.
Is there also a way to include the "close" button only in the javascript popup window?
---javascript---
<button onclick="window.close()" value="Close Window" />
<a href="rockin/bill.htm" target="_blank" onClick="newWindow('rockin/bill.htm');[b]" return false;[/b]>Rockin Bill,</a> javascript<br /> Moving 'return false;' inside the double quotes should fix you up.
As for your button, my first thought would be to have some Javascript at the end of the page check whether the 'opener' object was null and, if so, set the button's style to
display:none. There's probably something more elegant, but I think that'll work.
I want to insert this:
<button onclick="window.close()" value="Close Window" />Close Window
onto a htm page. I only want it to appear on the page that opens with javascript. When a browser access' it through 'a href' then I don't want it to be there.
Would writing an if/else statement hide the close button from non-javascript enabled browsers? This is probably way off from where it needs to be, but this is what may be needed on each htm page.
Any ideas?
if (javascript enabled) {
<button onclick="window.close()" value="Close Window" />Close Window
}
else (no javascript){
null;
}
<script type="text/javascript">
document.write("<button onclick='window.close()' value='Close Window' />")
</script>