PDA

View Full Version : shtml



marringi
06-19-2007, 09:30 PM
is is possible use javascript to write in shtml (<!--#include virtual="...)?
I'm using a small javascript to write in info location (document.writeIn)..

This is what I've been trying to use but it is not working:

function lid.markaskor.pr()
{
var paramValue;
var param2Value;

if( paramValue=window.location.search.match(/[?&]year=(\w+)/) )
document.write('<!--#include virtual="cgi-bin/?info=.');
document.write( paramValue[1] );
if( param2Value=window.location.search.match(/[?&]team=(\w+)/) )
document.write('&search=');
document.write( param2Value[1] );
document.write('" -->');
}

Twey
06-19-2007, 10:27 PM
No, it isn't possible, since the code is executed server-side before the Javascript is even sent to the browser. Even if it could be done (which it probably can with some escaping of quotes server-side, but I don't think SSI is capable of this and it would be horribly inefficient anyway because you'd have to load all the pages into the client's memory) it shouldn't be. There's no reason the above code can't be done entirely server-side.

lid.markaskor.pr is also an invalid function name. You could do:
window['lid.markaskor.pr'] = function() {
/* ... code ... */
};

// and call it like:
window['lid.markaskor.pr']();or:
var lid = {
markaskor : {
pr : function() {
/* ... code ... */
}
}
};

// and call it like:
lid.markaskor.pr();but not:
function lid.markaskor.pr() {
/* ... code ... */
}

marringi
06-19-2007, 10:31 PM
could you show me how?

Twey
06-19-2007, 10:35 PM
As I said, I don't believe SSI is capable of it. You'd need a fully-fledged server-side language.

marringi
06-19-2007, 10:53 PM
Do you know of a way that I can get information from the location URL (..?info1=file1&info2=file2) into the <!--#include virtual="URL" -->?
so I can use fewer template files..

djr33
06-19-2007, 11:33 PM
Sure. Use PHP. (Or ASP, JSP, some other form of CGI, such as PERL, python, etc.)