Home > Web Front-end > JS Tutorial > js gets html parameters and transfers parameters to swf application introduction_javascript skills

js gets html parameters and transfers parameters to swf application introduction_javascript skills

WBOY
Release: 2016-05-16 17:41:48
Original
1417 people have browsed it

We know that HTML pages are executed on the client side, so client-side scripts (such as JavaScript) must be used to obtain parameters. This is different from the way server-side scripts obtain parameters.

The following js code obtains all the parameters after the "?" of the HTML web page.

Copy code The code is as follows:



1. The following js code can obtain a certain parameter of the HTML web page in more detail
Copy code The code is as follows:



2. Pass to swf in HTML web page Parameters
Method 1: Use js in the web page, SetVariable to set the variables in the flashobject, the code is as follows:
Copy code The code is as follows:

// "HtmlToSwf" is the flashobject ID in the web page
HtmlToSwf.SetVariable("_root.info_str", "Happy Newyear");

Method 2: Path parameters, such as test.swf?foo=happy2005
Method 3: Use FlashVars. The following mainly introduces the usage of FlashVars. The flashobject code embedded in HTML after using FlashVars is as follows:
Copy code The code is as follows:

< object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0 " width="550" height="400" id="FlashVars" align="middle"> string 5

< param name="movie" value="FlashVars.swf" />





By the above code , you can directly obtain foo, program, and language variable data in SWF (FlashVars.swf). The code for FlashVars.fla to obtain the FlashVars parameters is as follows:
Copy code The code is as follows:

// Create three text fields
_root.createTextField("foo_txt",1,0,0,16,16);
_root.createTextField("program_txt",2,0,32,16,16);
_root.createTextField("language_txt",3,0,64,16,16);
foo_txt.autoSize = true;
String 8
foo_txt.border = true;
program_txt. autoSize = true;
program_txt.border = true;
language_txt.autoSize = true;
language_txt.border = true;
// Get FlashVars variable
foo_txt.text = "in HTML foo parameter: " foo;
program_txt.text = "program parameter in HTML:" program;
language_txt.text = "language parameter in HTML:" language;

3. 두 가지의 효과적인 결합
js를 사용하여 HTML 웹페이지에서 매개변수를 얻은 다음, 얻은 매개변수를 FlashVars로 flashobject에 작성하고 swf에 전달합니다. 코드는 다음과 같습니다.
코드 복사 코드는 다음과 같습니다.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template