Forum Moderators: open

Message Too Old, No Replies

Help! JS inside JS, how to?

how to insert js scrit inside js script?

         

colombo

7:32 pm on Apr 16, 2009 (gmt 0)

10+ Year Member



Hello,
I use some cool JS script to load flash game inside JS pop up, the issue is that i can write HTML in the pop up window but i can't write JS in it.

Here is the working version (HTML only):

<script type="text/javascript">

var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}

var w=640
var h=480
var ra;
if ((w/h)>(4/3))
ra=0.75;
else
ra=0.85;
var max_h=windowHeight*ra;
var ratio=max_h/480;
var max_w=w*ratio;
if (max_w>windowWidth)
max_w=windowWidth

dw_init({
//Common
winID:"window1",
content:"<div align=\"center\" style=\"width:100%; height:100%; background-color:#000000\">\n<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"100%\" height=\"100%\" title=\"game\" align=\"middle\">\n <param name=\"movie\" value=\"http://www.domain.com/files/24bdfd869fc131bc.swf\" />\n <param name=\"quality\" value=\"high\" />\n <embed src=\"http://www.domain.com/files/24bdfd869fc131bc.swf\" quality=\"high\" align=\"middle\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"100%\" height=\"100%\"></embed>\n </object>\n</div>\n ",
contentType:"text",
title:"&#1502;&#1513;&#1497;&#1502;&#1492; &#1489;&#1495;&#1500;&#1500;",

//Actions
openAfter:0,
onePerSession:0,

onMouseOver:"",
onMouseOut:"",
onClick:"game",

closeAfter:"",

//Size and position
width:max_w,
height:max_h,
vAlign:"middle",
hAlign:"center",

fullscreen:1,
minimizable:0,
closable:1,
resizable:1,

//Appearance
scrollbars:0,
moveEffect:"middle",
fadeEffect:0,
opacity:100,
floatable:1,
modal:0,
skin:"windows_safari",

skinJS:"http://www.domain.com/deluxe-popup-window.files/jaw_skin_windows_safari.js",
skinCSS:"http://www.domain.com/deluxe-popup-window.files/jaw_skin_windows_safari.css",
skinFiles:["deluxe-popup-window.files/border-00.gif",
"http://www.domain.com/deluxe-popup-window.files/border-01.gif",
"http://www.domain.com/deluxe-popup-window.files/border-02.gif",
"http://www.domain.com/deluxe-popup-window.files/border-10.gif",
"http://www.domain.com/deluxe-popup-window.files/border-12.gif",
"http://www.domain.com/deluxe-popup-window.files/border-20.gif",
"http://www.domain.com/deluxe-popup-window.files/border-21.gif",
"http://www.domain.com/deluxe-popup-window.files/border-22.gif",
"http://www.domain.com/deluxe-popup-window.files/close.gif",
"http://www.domain.com/deluxe-popup-window.files/fullscreen.gif",
"http://www.domain.com/deluxe-popup-window.files/jaw_skin_windows_safari.css",
"http://www.domain.com/deluxe-popup-window.files/jaw_skin_windows_safari.js",
"http://www.domain.com/deluxe-popup-window.files/min.gif",
"http://www.domain.com/deluxe-popup-window.files/resizer.gif",
"http://www.domain.com/deluxe-popup-window.files/restore.gif"]});

</script>

and i would like to replace it with that code (calling the flash file with JS):

<script type="text/javascript">

var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}

var w=640
var h=480
var ra;
if ((w/h)>(4/3))
ra=0.75;
else
ra=0.85;
var max_h=windowHeight*ra;
var ratio=max_h/480;
var max_w=w*ratio;
if (max_w>windowWidth)
max_w=windowWidth

dw_init({
//Common
winID:"window1",
content:"<div align=\"center\" style=\"width:100%; height:100%; background-color:#000000\">\n

<div id="flashcontent">
<strong>You need to upgrade your Flash Player</strong>
This is replaced by the Flash content.
Place your alternate content here and users without the Flash plugin or with
Javascript turned off will see this. Content here allows you to leave out <code>noscript</code>
tags. Include a link to <a href="swfobject.html?detectflash=false">bypass the detection</a> if you wish.
</div>

<script type="text/javascript">
// <![CDATA[

var so = new SWFObject("so_tester.swf", "sotester", "300", "300", "9", "#FF6600");
so.addVariable("flashVarText", "this is passed in via FlashVars for example only"); // this line is optional, but this example uses the variable and displays this text inside the flash movie
so.write("flashcontent");

[B][COLOR="Black"]// ]]>
</script>\

n</div>\n[/COLOR][/B] ",
contentType:"text",
title:"&#1502;&#1513;&#1497;&#1502;&#1492; &#1489;&#1495;&#1500;&#1500;",

//Actions
openAfter:0,
onePerSession:0,

onMouseOver:"",
onMouseOut:"",
onClick:"game",

closeAfter:"",

//Size and position
width:max_w,
height:max_h,
vAlign:"middle",
hAlign:"center",

fullscreen:1,
minimizable:0,
closable:1,
resizable:1,

//Appearance
scrollbars:0,
moveEffect:"middle",
fadeEffect:0,
opacity:100,
floatable:1,
modal:0,
skin:"windows_safari",

skinJS:"http://www.domain.com/deluxe-popup-window.files/jaw_skin_windows_safari.js",
skinCSS:"http://www.domain.com/deluxe-popup-window.files/jaw_skin_windows_safari.css",
skinFiles:["deluxe-popup-window.files/border-00.gif",
"http://www.domain.com/deluxe-popup-window.files/border-01.gif",
"http://www.domain.com/deluxe-popup-window.files/border-02.gif",
"http://www.domain.com/deluxe-popup-window.files/border-10.gif",
"http://www.domain.com/deluxe-popup-window.files/border-12.gif",
"http://www.domain.com/deluxe-popup-window.files/border-20.gif",
"http://www.domain.com/deluxe-popup-window.files/border-21.gif",
"http://www.domain.com/deluxe-popup-window.files/border-22.gif",
"http://www.domain.com/deluxe-popup-window.files/close.gif",
"http://www.domain.com/deluxe-popup-window.files/fullscreen.gif",
"http://www.domain.com/deluxe-popup-window.files/jaw_skin_windows_safari.css",
"http://www.domain.com/deluxe-popup-window.files/jaw_skin_windows_safari.js",
"http://www.domain.com/deluxe-popup-window.files/min.gif",
"http://www.domain.com/deluxe-popup-window.files/resizer.gif",
"http://www.domain.com/deluxe-popup-window.files/restore.gif"]});

</script>

the problem is with the <script> tag that is inside the <script> tag.

please help to to solve this problem :)

holyhttp

7:56 pm on Apr 22, 2009 (gmt 0)

10+ Year Member



For starter you could move your javascript code in a separate file and just use <script type="text/javascript" src="url-to-the-js-file" language="javascript"> </script>
tag in your HTML markup