PDA

View Full Version : Resolved Pop up window not opening



mlegg
10-02-2015, 06:05 PM
On this page (http://www.dynamicdrive.com/forums/showthread.php?78107-popup-window-modal-or-other&highlight=) I created, under the videos, a responsive grid of images thanks to Bev.

Sorry, I couldn't post the html, it said it was too long. Can you right click on the page and view the source?

This is a link (http://www.dynamicdrive.com/forums/showthread.php?78107-popup-window-modal-or-other&highlight=) that I asked about this a long time ago. I got it to work but now it doesn't.

thanks
Mike

styxlawyer
10-02-2015, 09:13 PM
That's probably because there's a 404 error on your linked pages. For example:

http://www.pscompetitiveedge.com/ltrs/bluewater.html

Have you misspelled a directory path?

mlegg
10-03-2015, 12:23 AM
Each image is linked to an htm page like this
<div class="grid"><a href="javascript:popUp('ltrs/bluewater.htm')"><img src="photos/logo/bluewater.jpg" alt="Bluewater Resort &amp; Casino" width="150" height="76" border="0"></a></div>

mlegg
10-03-2015, 12:24 AM
oops double post

styxlawyer
10-03-2015, 01:06 PM
Each image is linked to an htm page like this
<div class="grid"><a href="javascript:popUp('ltrs/bluewater.htm')"><img src="photos/logo/bluewater.jpg" alt="Bluewater Resort & Casino" width="150" height="76" border="0"></a></div>

Yes, I can see that in your source code, but the link created by the JavaScript doesn't lead anywhere! Try clicking on this link:

http://www.pscompetitiveedge.com/ltrs/bluewater.html

mlegg
10-04-2015, 02:51 AM
How can I fix this? I want people to be able to click on the logos on the page, and when they click on that, I want a popup window to open to show the letter from the company.
This used to work before but the last few months I changed the html on that page and may have missed something.

styxlawyer
10-04-2015, 05:05 PM
How can I fix this? I want people to be able to click on the logos on the page, and when they click on that, I want a popup window to open to show the letter from the company.
This used to work before but the last few months I changed the html on that page and may have missed something.

Nobody else can fix it for you, but here's some hints.

I don't know if you used the code from Arie or Beverley, but either way you have to find the JavaScript source for the popUp() function. I had a quick look at your page but couldn't see it so you may have deleted either the code or the link to the file containing the code in the <head></head> section of your page. Once you have found that code you need to see how it uses the path parameter which is passed to it. From reading your other thread I have assumed that the line:



<div class="grid"><a href="javascript:popUp('ltrs/bluewater.htm')"><img src="photos/logo/bluewater.jpg" alt="Bluewater Resort &amp; Casino" width="150" height="76" border="0"></a></div>


will create the following path for the popup window:



http://www.pscompetitiveedge.com/ltrs/bluewater.html


As I already wrote in post #2, that path gives a 404 error. It's possible that my assumption about the way the JavaScript function popUp() uses the parameter "ltrs/bluewater.html" is wrong but, if not, then either the directory "ltrs" or the file "bluewater.html" doesn't exist! Only you can fix that.

molendijk
10-04-2015, 07:03 PM
Hello Mike,
It seems you removed the popUp-script from your page. I don't know what the script looked like, so I made a new one for your. Put the following lines in the head section:

<script>
var alertmessage="The window you're about to open doesn't have buttons for 'back' and 'forward', but you can use the keyboard: \n- press the BACKSPACE button or ALT + left arrow for going back in the newly opened window, \n- use SHIFT+BACKSPACE or ALT + right arrow for going forward in the newly opened window."

function prompt_once_per_session()
{
if( !/(^|\s|;)seenAlert=yes(;|\s|$)/.test(document.cookie))
{if( !confirm(alertmessage+'\n\nClick on OK if you don`t want this message to show again.\n\nClick on CANCEL if you want this message to show each time you open a new window.') )
{}
else {document.cookie="seenAlert=yes";}
}
}

function windowsize()
{
window_height=Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight)
window_width=Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth)
w=window_width/(100/width), h=window_height/(100/height);
l = (window_width-w)/2-10;
t = 15+(window_height-h)/2;
}

function size_it(the_width,the_height)
{
width=the_width;
height=the_height;
windowsize();
}


function popUp(url,the_width,the_height)
{
size_it(the_width,the_height);
pop_it_up_prep(url)
}


var popUpWin ;
var url;
var autoclose = true;
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ;

function pop_it_up_prep(url){
if(is_chrome)prompt_once_per_session(); // message for Google Chrome users
if (popUpWin) {popUpWin.close()}
if (popUpWin && autoclose){window.onunload=function(){popUpWin.close()}}
popUpWin=window.open(url,"","menubar=no, toolbar=yes, titlebar=no, directories=no, status=0, scrollbars=yes,location=yes,top="+t+",left="+l+",width="+w+",height="+h+", resizable=1");
if (window.focus){popUpWin.focus() }

}
</script>
Then in the body use links like:

<div class="grid"><a href="javascript:popUp('http://www.pscompetitiveedge.com/ltrs/bluewater.htm', 80, 80)"><img src="http://www.pscompetitiveedge.com/photos/logo/bluewater.jpg" alt="Best Western" width="100" height="89" border="0"></a></div>

molendijk
10-04-2015, 07:56 PM
[...] will create the following path for the popup window:


http://www.pscompetitiveedge.com/ltrs/bluewater.html

As I already wrote in post #2, that path gives a 404 error. It's possible that my assumption about the way the JavaScript function popUp() uses the parameter "ltrs/bluewater.html" is wrong but, if not, then either the directory "ltrs" or the file "bluewater.html" doesn't exist! Only you can fix that.
Mike's links do work. The path is not http://www.pscompetitiveedge.com/ltrs/bluewater.html, but http://www.pscompetitiveedge.com/ltrs/bluewater.htm

mlegg
10-04-2015, 11:42 PM
it's working, I found my old page in my folder and forgot this in the head

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=675,height=465,left = 110,top = 45');");
}
// End -->

</script>

molendijk
10-04-2015, 11:52 PM
You might consider to replace the script you found on your old page with the one I gave you in post#8, because my script centers the popup and doesn't produce pop-up-after-popup when you repeatedly click on a link. But then, of course, you must adapt the HTML for the links as indicated in my post.

mlegg
10-05-2015, 12:01 AM
oh, I didn't know that.

Does 80, 80 center the image?
<div class="grid"><a href="javascript:popUp('http://www.pscompetitiveedge.com/ltrs/bluewater.htm', 80, 80)"

molendijk
10-05-2015, 08:05 AM
Yes, or 90,90, or 70,70, whatever you like. The numbers indicate percentages (width,height). There's a tutorial on it here (http://mesdomaines.nu/eendracht/window_open_of_tab_allerbest2/pop_it_up.html).
Note that popups don't exist in mobile devices, which always replace popups with new tabs.