Need advice please

Started by gerrymore, July 01, 2005, 05:52:36 PM

Previous topic - Next topic

gerrymore

I use javascript to open pop ups for forms etc elsewhere on my site. I usually add the following code imediatly before </head> (the code generator says anywhere between <head> and </head>). When I add this to index.template I get a template parse error. Is there something I should have added to this to make index.tmeplate to open as normal? Maybe I'm missing some quotes or something?


<script language='javascript'>
<!--
/********************************************
AUTHOR:WWW.CGISCRIPT.NET.LLC
URL:http://www.cgiscript.net
Use the code for FREE but leave this message intact
Download your FREE CGI/Perl Scripts today!
( http://www.cgiscript.net/scripts.htm )
****************************************************/
var acePopupWindow=null;
function acePopup(mypage,myname,w,h,pos,infocus){
if(pos=='random'){
LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=='center'){
LeftPosition=(screen.width)?(screen.width-w)/2:100;
TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!='random') || pos==null){LeftPosition=100;TopPosition=100;}settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,dependent=no';
acePopupWindow=window.open('',myname,settings);
if(infocus=='front'){acePopupWindow.focus();acePopupWindow.location='http://www.fun-times.co.uk/tour.php';}
}
//-->
</script>


I plan to launch the popup from a link in a thread.
SMF RC1, Tiny Portal 0.75, Coppermine 1.3.3, Flashchat.

Christian A. Herrnboeck

The problem is, that you need to escape all of the 's in your script... so, turn ' into \'.

-Christian


Farmers:Producing food for the world!

gerrymore

#2
Do you mean every single quote in the code should have a backslash in front of it?

Is this what you mean:

<script language=\'javascript\'>
<!--
/********************************************
AUTHOR:WWW.CGISCRIPT.NET.LLC
URL:http://www.cgiscript.net
Use the code for FREE but leave this message intact
Download your FREE CGI/Perl Scripts today!
( http://www.cgiscript.net/scripts.htm )
****************************************************/
var acePopupWindow=null;
function acePopup(mypage,myname,w,h,pos,infocus){
if(pos==\'random\'){
LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos==\'center\'){
LeftPosition=(screen.width)?(screen.width-w)/2:100;
TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!=\'center\' && pos!=\'random\') || pos==null){LeftPosition=100;TopPosition=100;}settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,dependent=no';
acePopupWindow=window.open('',myname,settings);
if(infocus==\'front\'){acePopupWindow.focus();acePopupWindow.location=\'http://www.fun-times.co.uk/tour.php\';}
}
//-->
</script>
SMF RC1, Tiny Portal 0.75, Coppermine 1.3.3, Flashchat.

Advertisement: