The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
JavaScript in Headiclude loops?
It would seem so as after inserting a bit of my own js to the end of the template the site refershes and refershes and refreshe sin an endless fashion.
Whats going wrong and cananyone comment on a place within the code that this js can be placed to allow the styleid to be set automatically upon a users visit, be they guest admin or whatever..?? Code:
var bbcount= 0; while (bbcount<1) { if ((screen.width>=1024) && (screen.height>=768)) { window.location="?styleid=22"; bbcount=bbcount+1; } else { window.location="?styleid=21"; bbcount=bbcount+1; } alert('We are experiencing a Javascript Issue and will be back shortly'); } I take it because the page reloads to set the new id its then re-executing this js over again Would it be wise to set a cookie with a value of 1 or 0 denpendant on if the script is run? That way i could use an if and see if the value is there and if not this would then be excecuted creating a cookie with the "has been run" value ? |
#2
|
||||
|
||||
My full script now reads
Code:
<script language="javascript"> var bbcount= 0; var aostyleon = getCookie("aostyleopt"); if (aostyleon != null) { } else { while (bbcount<1) { if ((screen.width>=1024) && (screen.height>=768)) { window.location="?styleid=22"; bbcount=bbcount+1; setCookie("aostyleopt", "set"); } else { window.location="?styleid=21"; bbcount=bbcount+1; setCookie("aostyleopt", "set"); } alert('We are experiencing a Javascript Issue and will be back shortly'); } } </script> |
#3
|
||||
|
||||
window.location will act like a refresh - it is a command function that will reload your script every time is comes to that instance.
So it should loop with what you have... You should be using javascript test is a styleid cookie is set, if not, then window.location to a script that does nothing but set this styleid cookie - then that script should come back to the test for the styleid cookie in the headinclude... Get it ? |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|