This topic is locked

cant add javascript within header on visual editor html

4/12/2007 9:02:07 AM
PHPRunner General questions
D
datapimp author

Hi
Just want to know if someone can help me with this ongoing problem I have.
Every time I add just about any kind of javascript within the header in the visual editor html section I get this error:
Error type 256

Error description Smarty error: [in drh_list.htm line 11]: syntax error: unbalanced parenthesis in if statement (Smarty_Compiler.class5.php, line 1265)

Error file C:\***\output\libs\Smarty.class5.php

Error line 1095
The code I was trying to enter is a simple button rollover script which is generated by photoshop cs2
I would like to know if there is any way around this?
Thanks in advance
Here is the code (fyi)
[codebox]<script type="text/javascript">

<!--
function newImage(arg) {

if (document.images) {

rslt = new Image();

rslt.src = arg;

return rslt;

}

}
function changeImages() {

if (document.images && (preloadFlag == true)) {

for (var i=0; i<changeImages.arguments.length; i+=2) {

document[changeImages.arguments[i]].src = changeImages.arguments[i+1];

}

}

}
var preloadFlag = false;

function preloadImages() {

if (document.images) {

del_ssv_04_over = newImage("images/del_ssv_04-over.jpg");

del_ssv_06_over = newImage("images/del_ssv_06-over.jpg");

del_ssv_08_over = newImage("images/del_ssv_08-over.jpg");

del_ssv_10_over = newImage("images/del_ssv_10-over.jpg");

preloadFlag = true;

}

}
// -->

</script>[/codebox]

J
Jane 4/12/2007

Hi,
use {literal} and {/literal} expression around your JavaScript code:

{literal}

<script type="text/javascript">

<!--

function newImage(arg)

{

...
...

}

// -->

</script>

{/literal}

D
datapimp author 4/12/2007

Thanks Jane
i seem to be have a strange problem,
i place the code just before the </head> tag, but when i switch out of html mode (in the visual editor) then go back to html mode i find that all by code between {literal} tag has moved just after the </body> tag. but the {literal}{/literal} is still inside the <head> tag ???
i tried a few times but the same thing keeps happening ????

D
datapimp author 4/12/2007

hi can jane or one of the admins please let me know if this is a problem from my end or a bug with phprunner?
thanks

Sergey Kornilov admin 4/12/2007

Visual Editor uses functionality that Internet Explorer provides to parse and display HTML code.

Unfortunately IE do not respect source code formatting and tend to move pieces of code around.
I'd say you need to find correct place for your javascript code using trial and error method.
Probably you can add yor code to header.php and reference it from other files.