Original Post
I'm trying to embed Javascript in a PHP document. At first I tried to have Javascript outputted to the browser using PHP's echo(), but it didn't seem to work.
Then I tried just using raw Javascript in combination with PHP, and it gave me a grey Flash window. That's pretty much where I'm stuck right now. The Javascript code was generated by a tool called AxMag. It works well enough on its own, but not when I try to embed it!
My directory structure is as follows:
Boligmagasinet
Boligmagasinet/tmpsites/
Boligmagasinet/tmpsites/Boligmagasinet nr.1 - 2011
I changed the following line:
from "sameDomain" to "always" because this article seemed to suggest it might be a good idea. It didn't seem to change anything though.
I also tried calling the php file with a url ending in '&page=1', but it didn't seem to change anything, either!
The original 'index.html' file generated by AxMag is as follows:
Any suggestions?
Edit: Is there any sane, reasonable way to debug Javascript? It seems to basically contain an error (since the flash animation isn't showing up), but I'm not sure where it is...
Then I tried just using raw Javascript in combination with PHP, and it gave me a grey Flash window. That's pretty much where I'm stuck right now. The Javascript code was generated by a tool called AxMag. It works well enough on its own, but not when I try to embed it!
<?php
$Magazine = $_GET['Magazine'];
echo("<html>");
echo("<!-- Created on:03/17/2011 02:34:19 pm-->");
echo("<head>");
echo(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
echo(" <title>" . $Magazine . "</title>");
echo(" <meta name=\"description\" content=\"\">");
echo(" <meta name=\"keywords\" content=\"bolig boliger boligmagasinet grafisk partner agder kristiansand evje hornes\">");
echo(" <meta name=\"author\" content=\"Mats Vederhus\">");
echo(" <meta name=\"generator\" content=\"AceHTML Freeware\">");
echo(" <img src=\"Boligmagasinet - headding.jpg\">");
echo(" <link rel=stylesheet href=\"mags-style.css\">");
echo("</head>");
echo("<body>");
echo(" <div class=\"hovermenu\">");
echo(" <ul>");
echo(" <li><a href=\"index.php\">Hjem</a></li>");
echo(" <li><a href=\"about.html\">Om oss</a></li>");
echo(" <li><a href=\"contact.html\">Kontakt</a></li>");
echo(" <li><a href=\"mags.php\">Magasiner</a></li>");
echo(" <li><a href=\"login.php\">Login</a></li>");
echo(" </ul>");
echo(" </div>");
/*echo(" <script language=\"JavaScript\"");
echo(" function getURLParam(strParamName){");
echo(" var strReturn = \"\";");
echo(" var strHref = window.location.href;");
echo(" if ( strHref.indexOf(\"?\") > -1 ){");
echo(" var strQueryString = strHref.substr(strHref.indexOf(\"?\")).toLowerCase();");
echo(" var aQueryString = strQueryString.split(\"&\");");
echo(" for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){");
echo(" if ( aQueryString[iParam].indexOf(strParamName.toLowerCase() + \"=\") > -1 ){");
echo(" var aParam = aQueryString[iParam].split(\"=\");");
echo(" strReturn = aParam[1];");
echo(" break;");
echo(" }");
echo(" }");
echo(" }");
echo(" return unescape(strReturn);");
echo(" }");
echo(" document.write(");
echo(" '<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n'+");
echo(" ' codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\"\n'+");
echo(" ' WIDTH=\"100%\" HEIGHT=\"100%\" id=\"idswf\" align=\"TL\">\n'+");
echo(" ' <PARAM NAME=\"allowScriptAccess\" value=\"sameDomain\" />\n'+");
echo(" ' <PARAM NAME=\"allowFullScreen\" value=\"false\" />\n'+");
echo(" ' <PARAM NAME=movie '+");
echo(" ' VALUE=\"" . "tmpsites/" . $Magazine . "/main.swf?page='+getURLParam('page')+'\" />\n'+");
echo(" ' <PARAM NAME=quality VALUE=high />\n'+");
echo(" ' <PARAM NAME=bgcolor VALUE=#888888 />' +");
echo(" ' <PARAM NAME=scale VALUE=noscale />\n'+");
echo(" ' <PARAM NAME=align VALUE=TL />\n'+");
echo(" ' <PARAM NAME=salign VALUE=TL />\n'+");
echo(" ' <EMBED src=\"" . "tmpsites/" . $Magazine . "/main.swf?page=' + getURLParam('page') + '\"' +");
echo(" ' bgcolor=#888888 WIDTH=\"100%\" HEIGHT=\"100%\" '+");
echo(" ' quality=\"high\"' +");
echo(" ' scale=\"noscale\"' +");
echo(" ' name=\"nameswf\"' +");
echo(" ' align=\"TL\"' +");
echo(" ' salign=\"TL\"' +");
echo(" ' allowFullScreen=\"false\"' +");
echo(" ' TYPE=\"application/x-shockwave-flash\"'+");
echo(" ' />\n'+");
echo(" '</OBJECT>\n');");
echo(" </script>");*/
?>
<script language="JavaScript">
function getURLParam(strParamName){
var strReturn = "";
var strHref = window.location.href;
if ( strHref.indexOf("?") > -1 ){
var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
var aQueryString = strQueryString.split("&");
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
if ( aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
var aParam = aQueryString[iParam].split("=");
strReturn = aParam[1];
break;
}
}
}
return unescape(strReturn);
}
var Magazine = getURLParam('Magazine');
document.write(
'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n'+
' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"\n'+
' WIDTH="100%" HEIGHT="100%" id="idswf" align="TL">\n'+
' <PARAM NAME="allowScriptAccess" value="always" />\n'+
' <PARAM NAME="allowFullScreen" value="true" />\n'+
' <PARAM NAME=movie '+
' VALUE="tmpsites/'+Magazine+'/main.swf?page='+getURLParam('page')+'" />\n'+
' <PARAM NAME=quality VALUE=high />\n'+
' <PARAM NAME=bgcolor VALUE=#888888 />' +
' <PARAM NAME=scale VALUE=noscale />\n'+
' <PARAM NAME=align VALUE=TL />\n'+
' <PARAM NAME=salign VALUE=TL />\n'+
' <EMBED src="tmpsites/'+Magazine+'/main.swf?page=' + getURLParam('page') + '"' +
' bgcolor=#888888 WIDTH="100%" HEIGHT="100%" '+
' quality="high"' +
' scale="noscale"' +
' name="nameswf"' +
' align="TL"' +
' salign="TL"' +
' allowFullScreen="true"' +
' TYPE="application/x-shockwave-flash"'+
' />\n'+
'</OBJECT>\n');
</script>
<?php
echo("</body>\n");
echo("<footer>\n");
echo(" <b>Made by Mats Vederhus for Grafisk Partner avdeling Agder</b>\n");
echo("</footer>\n");
echo("</html>");
?>My directory structure is as follows:
Boligmagasinet
Boligmagasinet/tmpsites/
Boligmagasinet/tmpsites/Boligmagasinet nr.1 - 2011
I changed the following line:
' <PARAM NAME="allowScriptAccess" value="always" />\n'+from "sameDomain" to "always" because this article seemed to suggest it might be a good idea. It didn't seem to change anything though.
I also tried calling the php file with a url ending in '&page=1', but it didn't seem to change anything, either!
The original 'index.html' file generated by AxMag is as follows:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>Boligmagasinet nr 1 - 2011 - Powered by aXmag</title>
</head>
<body bgcolor="#888888" style="margin:0px" >
<!-- saved from url=(0013)about:internet -->
<script language="JavaScript" type="text/javascript">
function getURLParam(strParamName){
var strReturn = "";
var strHref = window.location.href;
if ( strHref.indexOf("?") > -1 ){
var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
var aQueryString = strQueryString.split("&");
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
if ( aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
var aParam = aQueryString[iParam].split("=");
strReturn = aParam[1];
break;
}
}
}
return unescape(strReturn);
}
document.write(
'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n'+
' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"\n'+
' WIDTH="100%" HEIGHT="100%" id="idswf" align="TL">\n'+
' <PARAM NAME="allowScriptAccess" value="sameDomain" />\n'+
' <PARAM NAME="allowFullScreen" value="true" />\n'+
' <PARAM NAME=movie '+
' VALUE="main.swf?page='+getURLParam('page')+'" />\n'+
' <PARAM NAME=quality VALUE=high />\n'+
' <PARAM NAME=bgcolor VALUE=#888888 />' +
' <PARAM NAME=scale VALUE=noscale />\n'+
' <PARAM NAME=align VALUE=TL />\n'+
' <PARAM NAME=salign VALUE=TL />\n'+
' <EMBED src="main.swf?page=' + getURLParam('page') + '"' +
' bgcolor=#888888 WIDTH="100%" HEIGHT="100%" '+
' quality="high"' +
' scale="noscale"' +
' name="nameswf"' +
' align="TL"' +
' salign="TL"' +
' allowFullScreen="true"' +
' TYPE="application/x-shockwave-flash"'+
' />\n'+
'</OBJECT>\n');
</script>
</body>Any suggestions?
Edit: Is there any sane, reasonable way to debug Javascript? It seems to basically contain an error (since the flash animation isn't showing up), but I'm not sure where it is...