Popupwindow focus problem

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Popupwindow focus problem

Post by Shendemiar »

I'm having some additional data in popupwindow. Opening goes ok, if i close it it remembers it's location etc. But i cant make it become in front. It opens in front, but after that it stays behind. Any links opening there opens fine, but it doesnt come in front.

Included in HEAD, sripts part:

Code: Select all

<?php
echo "var newWindow = null;";     
?>
Script:

Code: Select all

function makeNewWindow(url, name, features)
&#123;
newWindow = open(url, name, features);
if (newWindow &amp;&amp; !newWindow.closed)
newWindow.focus();
return false;
&#125;
Call:

Code: Select all

<?php
echo "<a href="index.php?MM=kysymykset&UKK_Vastaus=$UKK_V_ID" target="UKK" 
onclick="return makeNewWindow(this.href,this.target,'width=900,height=600,left=50,location,scrollbars')">Something</a>";
?>
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

I added the $Pop_UP to the page body tag:

if ($_GET['MM']=="kysymykset")
$Pop_Up="onLoad=\"window.focus()\" ";
}

<body $Pop_Up>

and now it comes forward if i reload something into it
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

When you say 'front' are you reffering to modal?.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Joe wrote:When you say 'front' are you reffering to modal?.
Mmm.. sorry, i don't understand :o

Front for me here = window shows in front of all other windows
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Yes modal is when the window is in front of all other windows. My suggestion is to use vbscript instead of javascript for this task. Something like:

Code: Select all

<script language="vbscript">
msgbox ("Hello"), vbmodal
</script>
Notice I made the popupbox modal?.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

I forgot to mention. A javascript alternative would be, showModalDialog()
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Would be fine for alerts and simple data, but i need to run php and show complex html.

Anyway, i got my problem solved, well not exactly, but worked around at least ;)
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

If you were looking for html to be shown then try showModalDialog() in javascript. It works perfect.
Post Reply