This is a discussion on "detect pop-up blocker - different" within the JavaScript Forum section. This forum, and the thread "detect pop-up blocker - different are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
detect pop-up blocker - different
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
detect pop-up blocker - different
Hello,
I have a web site I am developing. The web page has a photography gallery portfolio on it with thumbnails. When the thumbnail are clicked on, they open in a new window. I would like to add to the javascript a detection and alert that notifies the user that the window did not open due to a popup blocker. Could somebody please help me with this, I can't figure out how to do it on my own. Here is the original javascript for the window opener script: <script language="JavaScript" type="text/JavaScript"> <!-- function viewPic(img) { picfile = new Image(); picfile.src =(img); fileCheck(img); } function fileCheck(img) { if( (picfile.width!=0) && (picfile.height!=0) ) { makeWindow(img); } else { funzione="fileCheck('"+img+"')"; intervallo=setTimeout(funzione,10); } } function makeWindow(img) { ht = picfile.height; wd = picfile.width; var args= "height=" + ht + ",innerHeight=" + ht; args += ",width=" + wd + ",innerWidth=" + wd; if (window.screen) { var avht = screen.availHeight; var avwd = screen.availWidth; var xcen = (avwd - wd) / 2; var ycen = (avht - ht) / 2; args += ",left=" + xcen + ",screenX=" + xcen; args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=no"; } popwin=window.open("","_blank",args) popwin.document.open() popwin.document.write('<html><head><title>'+img+'</title></head><body bgcolor=black scroll=no topmargin=0 leftmargin=0 rightmargin=0 bottomargin=0 marginheight=0 marginwidth=0><div style="position: absolute; top:0px;left:0px">[img]'+img+'[/img]</div></body></html>') popwin.document.close() } //--> </script> Now, I tried to modify that script, here is what I added to it: ------- popwin=window.open("","_blank",args) popwin.document.open() if (popwin==null || typeof(popwin)=="undefined") { alert("window failed to open"); } else { popwin.document.write('<html><head><title>'+img+'</title></head><body bgcolor=black scroll=no topmargin=0 leftmargin=0 rightmargin=0 bottomargin=0 marginheight=0 marginwidth=0><div style="position: absolute; top:0px;left:0px">[img]'+img+'[/img]</div></body></html>') popwin.document.close() } } -------- If somebody would be able to help me, it would be greatly appreciated. Thank you so much. |
|
|
![]() |
| Tags |
| detect, popup, blocker, different |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Popup Name Detect | RobinDeanDotCom | JavaScript Forum | 0 | Feb 24th, 2007 22:35 |
| Script to detect flash? | fezunit | JavaScript Forum | 5 | Jan 28th, 2007 12:18 |
| Detect IE | Totti | JavaScript Forum | 4 | Dec 6th, 2006 00:48 |
| Possible to detect which stylesheet in use? | mar2195 | JavaScript Forum | 9 | Nov 25th, 2006 11:43 |
| Detect whether connection to external url is possible | simonneaves | Classic ASP | 3 | Oct 24th, 2005 13:12 |