Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Javascript *not* printing exactly (site_html.pl)

Quote Reply
Javascript *not* printing exactly (site_html.pl)
Hi,

On one of my client websites I use some Javascript to detect a Flash plugin, but Links is not printing the code completely.

Part of the code contains \n's which should be printed into the javascript/HTML, however links is treating it like a perl newline and simply printing the rest of the javascript on the next line.

Here's the original code from the site_html.pl file:

Code:
<SCRIPT LANGUAGE=JavaScript1.1>
<!--
var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words)))
continue;
var MM_PluginVersion = words;
}
var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {
document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next \n');
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {
} else{
window.location.replace(http://www.wcsauto.com/noflash.html);
}
//-->
</SCRIPT>


Here's the actual code from the Links generated HTML file:

Code:


<SCRIPT LANGUAGE=JavaScript1.1>
<!--
var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words)))
continue;
var MM_PluginVersion = words;
}
var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {
document.write('<SCR' + 'IPT LANGUAGE=VBScript>
'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next
');
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))
');
document.write('</SCR' + 'IPT>
');
}
if ( MM_FlashCanPlay ) {
} else{
window.location.replace("http://www.wcsauto.com/noflash.html");
}
//-->
</SCRIPT>


Any advice on how to force the \n's to be printed would be much appreciated?

All the best
Shaun

Last edited by:

qango: Aug 6, 2003, 1:26 AM
Quote Reply
Re: [qango] Javascript *not* printing exactly (site_html.pl) In reply to
You tried escaping them?

\\n

Unsure

Either that, or try using q| ... |; to hold/print the javascript (I'm assuming you know what q| |; does Tongue)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Aug 6, 2003, 1:55 AM
Quote Reply
Re: [Andy] Javascript *not* printing exactly (site_html.pl) In reply to
Andy,

Thanks, I escaped them and now they work perfectly Smile

All the best
Shaun