Topic: Javascript problem (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=27992" title="Pages that link to Topic: Javascript problem (Page 1 of 1)" rel="nofollow" >Topic: Javascript problem <span class="small">(Page 1 of 1)</span>\

 
EDDII
Bipolar (III) Inmate

From:
Insane since: May 2004

IP logged posted posted 05-25-2006 14:51 Edit Quote

ok i have this code which opens a centralised new window with the home page then sets the browser to refresh after 5 seconds to the home page

code:
<script language="Javascript">
   	function Redirect() {
	window.location="home.htm";
    }
	function NewWindow() {
	left=(700-screen.width)/2;
	top=(150-screen.height)/2;
	window.open("home.htm", "main", "resizable=1,HEIGHT=423,WIDTH=700,left=150,top=150,screenX=left,screenY=top");
	Refresh=setTimeout("Redirect()",5000);
	}
    function Stopit() {
    clearTimeout(Refresh);
    }
	</script>


then in the body tag on the "home.htm" page

code:
onload="javascript: window.opener.Stopit()"


the idea of this (incase its not obvios) is so that if the window doesnt open for some reason then the browser will go to the homepage anyway
alright so anyway. My problem is, it doesn't work in IE i found it works fine on other browsers i tested it on but not IE for some reason and i have no idea why
first off the popup doesnt come up, and then it doesnt redirect either
any help appreciated

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

IP logged posted posted 05-26-2006 18:00 Edit Quote

Nothing pops right out except I'd take out the "javascript: " you shouldn't need it on event handlers so it might be screwing something up.



.:[ Never resist a perfect moment ]:.

EDDII
Bipolar (III) Inmate

From:
Insane since: May 2004

IP logged posted posted 05-26-2006 20:15 Edit Quote

there is one little mistake in there, about the "left" and "top" but that wasnt the main problem
it seems to be working now thanks

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 05-27-2006 23:51 Edit Quote

the javascript: is unecessary but doesn't screw the things up. IMHO what's wrong is the scope of the Refresh variable. It's only declared and assigned in the newWindow function, so it is unknown in the stopIt function. Simply add a

code:
var Refresh

outside of all functions so the variable is available and known from every functions, and voilà.

Hope that helps,



(Edited by poi on 05-27-2006 23:52)

EDDII
Bipolar (III) Inmate

From:
Insane since: May 2004

IP logged posted posted 05-28-2006 00:24 Edit Quote

ok that helps too thanks
in your opinion is it good?
i think this is acutally probably the first thread i've started where the first response wasn't something like "well why would you want to do that" or "that's a really ineficient way of doing that"

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 05-28-2006 19:26 Edit Quote

Hard to say if its "good" or not, I think having an alternative incase a popup doesnt work is a great idea. Was that your question or where you asking about code efficiency or something along those lines?

Does "onload="javascript: window.opener.Stopit()" cause an error if its opened inside window instead of a popup? You may need a if(window.opener) in a seperate function.

Does anyone know the general rule for popup blockers? As far as I knew it only blocks popups set on the onload directly or if its run as the code is read.

liorean
Bipolar (III) Inmate

From: Umeå, Sweden
Insane since: Sep 2004

IP logged posted posted 05-29-2006 01:36 Edit Quote

Opera and Firefox popup blockers* are quite sophisticated I think. They are trying to block any way of causing popups that is not a direct effect of user interaction. IIRC they do stuff like marking events as user triggered versus script triggered etc. as filter methods for determining whether the popup should be allowed or not, and default to not allowing it.


* Don't know about iew's blocker or those you get with antiviri, adware removers, proxies or firewall software.

--
var Liorean = {
abode: "http://codingforums.com/",
profile: "http://codingforums.com/member.php?u=5798"};



Post Reply
 
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
 
Your Text:
Loading...
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu