Why JavaScript, generated in CGI Wrapper, doesnt work!?

slilov

New Member
Hi!

I have a CGI Wrapper, which generates a HTML page. But I want to include in it a Javascript file, like this:

...
{&OUT} '<SCRIPT language="JavaScript" src="source.js"></SCRIPT>'
...

It's simple code, but generates Syntax error, when executed in my browser (IE5) via WebSpeed agent.

When, after error message, I copy the same generated HTML code from the browser (using "View Source") and paste it into another new HTML file and then open it directly with my browser (not via WebSpeed agent), it works OK (no syntax errors).

Who's wrong - me or WebSpeed?

Simeon Lilov
 
U

Unregistered

Guest
It sounds to me that the problem is in your code.

I'm not entirely sure what you are trying to do but I hope the sample code from a CGI wrapper below helps.

RUN outputHeader.

{&OUT}
"<HTML>":U SKIP
"<HEAD>":U SKIP
"<TITLE> {&FILE-NAME} </TITLE>":U SKIP
"<script Language='JavaScript' src='/scripts/test.js'></script>"


"</HEAD>":U SKIP
"<BODY>":U SKIP
"<script language='Javascript'>"
"functionintestjs();"
"</script>".


The code generates the HTML page and references a javascript include file.
 

slilov

New Member
Sorry, my code doesn't appear as i typed it

I typed my code example in plain HTML, but when I posted it and look at it, it was only a part of it. I think it's because of tag's brackets.
Here is my example, where tag's angular brackets are replaced with rounded brackets, just for properly displaing.


...
{&OUT} '(SCRIPT language="JavaScript" src="source.js")(/SCRIPT)'.
...


BTW, I can't see any code between quotes in first reply of my question (by 'Unregistered'). Is this because of tag's brackets again?
 

p.koppers

New Member
hi,

I'm not sure if it will work, but I do know that when generation
javascript with javascript (with document.write()) you have to
split up the word script in the tag &lt;script&gt; like this:
"&lt;SCR" + "IPT&gt;" (also in the trailing tag off course).
Maybe it also works this way with webspeed ?

(ps. if you're wondering how I got the &lt; and &gt; in my reply,
I used the html symbols &amp;lt; and &amp;gt; )
 

cup99

New Member
when you are using {&OUT} to have webspeed output any javascript you have to use ~ in front of the end tag of script.

The code below shows this:

{&OUT}
'<script language="javascript">'
'window.opener.AddItem("' branch.branchname '","' branch.branchcode '",true);'
'<~/script>'.
 

slilov

New Member
Thanks to all, I found my mistake myself

Here is my mistake:

Specifying the .JS file, I didn't use full path to it (URL) like this:
"//server/workfolder/file.js". Instead I used only "file.js". I was thinking that because 'workfolder' is my WebSpeed's working directory, I needn't use full URL to .JS file. But obviously I have to.

BTW, if we want to use any HTML sample on this forum, we must use some representation of tag's brackets, like &amp;lt; and &amp;gt;, which produce &lt; and &gt; (thanks to P.Koppers)

Thanks all again!
 
Top