webLamHo 2012-12-11
代码如下:
<script type="text/javascript">
/* Get URL Parameter in Javascript. Code from: http://mattwhite.me/11tmr.nsf/D6Plinks/MWHE-695L9Z */
function getURLParam(strParamName){
var strReturn = "";
var strHref = window.location.href;
if ( strHref.indexOf("?") > -1 ){
var strQueryString = strHref.substr(strHref.indexOf("?"));
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);
}
</script> 代码如下:
<div id="flashcontent"> <strong>This content requires Flash Player 9 (or a more recent version). <noscript>Make sure JavaScript is turned on. </noscript> You need to <a href="http://www.adobe.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash" target="_blank"> <span style="text-decoration: underline;">upgrade your Flash Player</span></a></strong> </div>
代码如下:
<script type="text/javascript">
var flashvars = { test:getURLParam("test") };
var params = {};
var attributes = {};
swfobject.embedSWF("/articlefiles/jsvars/jsvars.swf", "flashcontent", "550", "400", "9.0.0","", flashvars, params, attributes);
</script> 代码如下:
try {
var key:String; // This will contain the name of the parameter
var val:String; // This will contain the value of the parameter
var flashvars:Object = LoaderInfo(this.root.loaderInfo).parameters;
for (key in flashvars) {
val = String(flashvars[key]);
mytextField.text = key+": "+val;
}
} catch (error:Error) {
// what to do if an error occurs
} 代码如下:
try {
var key:String;
var val:String;
var flashvars:Object = LoaderInfo(this.root.loaderInfo).parameters;
for (key in flashvars) {
val = String(flashvars[key]);
variablesReceived.appendText("\t" + key + ": " + val + " ");
}
} catch (error:Error) {
variablesReceived.appendText(error.toString());
} 代码如下:
// Sending parameters
function sendVariables(e:MouseEvent):void {
// First we grab the URL of the HTML document and split it into an array
var htmlUrl:String = ExternalInterface.call("window.location.href.toString");
// split the string at the questionmark
var splitUrl:Array = htmlUrl.split("?");
// use only the first part (ditch existing parameters)
var trimmedUrl:String = splitUrl[0];
// get the parameters we want to append to the URL
var parameters:String = variablesToSend.text;
// combine url and parameters with a new questionmark
var requester:URLRequest = new URLRequest(trimmedUrl+"?"+parameters);
// reload the page
navigateToURL(requester, '_self');
} 代码如下:
// grab variables
try {
var key:String;
var val:String;
var flashvars:Object = LoaderInfo(this.root.loaderInfo).parameters;
for (key in flashvars) {
val = String(flashvars[key]);
if(key == "item"){ // If the parameter is called 'item'...
if(val.substr(0,4) == "item"){ // ... and the name of the button starts with the characters 'item'...
// ... we can extract the number-part of the item-name and go to the correct frame
var frameToGoTo:Number = Number( val.substr(4,1) );
gotoAndStop( frameToGoTo+1 );
}
}
}
} catch (error:Error) {
// what to do if an error occurs
} 代码如下:
// Get the new page
function gotoURL(e:MouseEvent):void {
// First we grab the URL of the HTML document and split it into an array
var htmlUrl:String = ExternalInterface.call("window.location.href.toString");
// split the string at the questionmark
var splitUrl:Array = htmlUrl.split("?");
// use only the first part (ditch existing parameters)
var trimmedUrl:String = splitUrl[0];
// get the name of the button clicked and set it as a parameter
var parameters:String = "item="+e.currentTarget.name;
// combine url and parameters with a new questionmark
var requester:URLRequest = new URLRequest(trimmedUrl+"?"+parameters);
// reload the page
navigateToURL(requester, '_self');
}