2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > js获取html参数及向swf传递参数应用介绍【javascript】

js获取html参数及向swf传递参数应用介绍【javascript】

时间:2022-12-30 00:11:22

相关推荐

js获取html参数及向swf传递参数应用介绍【javascript】

web前端|js教程

html参数,swf参数

web前端-js教程

我们知道HTML页面是在客户端执行的,这样要获取参数必须使用客户端脚本(如JavaScript),在这点上不同于服务器端脚本获取参数方式。

源码目录,vscode高俄罗斯方,ubuntu搭建snmp,tomcat支持多少访问,定时增量爬虫,php 页面 全局变量,抖音seo运营系统代理,简单文件上传下载网站源码,兑换券 模板lzw

下面的这段js代码获取HTML网页形如”test.html?foo=mytest&program=flash” “?”后所有参数。

漂亮的二级域名源码,ubuntu配双网卡,java简易网页爬虫,php网页生成,产品seo设置lzw

<!--

var hrefstr,pos,parastr;

hrefstr = window.location.href;

pos = hrefstr.indexOf("?");

parastr = hrefstr.substring(pos 1);

if (pos>0){

document.write("所有参数:" parastr);

} else {

document.write("无参数");

}

//-->

A、下面的这段js代码则可以更加细化获取HTML网页某一参数

h5模板源码,vscode大纲关闭,商用Ubuntu,tomcat窗口保留,sqlite怎么默认为空,wordpress 图片切换插件,前端核心框架结构有哪些,定制化的网络爬虫系统,php html实体,徐州seo优化战略,免费学校网站管理系统,网页在线聊天实现,好看的免费视频网站模板lzw

<!--

function getparastr(strname) {

var hrefstr,pos,parastr,para,tempstr;

hrefstr = window.location.href;

pos = hrefstr.indexOf("?") 字串9

parastr = hrefstr.substring(pos 1);

para = parastr.split("&");

tempstr="";

for(i=0;i<para.length;i )

{

tempstr = para[i];

pos = tempstr.indexOf("=");

if(tempstr.substring(0,pos) == strname) {

return tempstr.substring(pos 1);

}

}

return null;

}

// 获取program参数

var programstr = getparastr("program");

document.write(programstr);

//-->

B、在HTML网页中向swf传递参数

方法一:在网页中使用js,SetVariable设置flashobject中的变量,代码如:

// "HtmlToSwf"为网页中的flashobject ID

HtmlToSwf.SetVariable("_root.info_str","Happy Newyear");

方法二:路径参数,如test.swf?foo=happy

方法三:使用FlashVars,以下主要介绍FlashVars的用法。使用FlashVars后嵌入HTML的flashobject代码如下:

字串5

通过上面的代码,在SWF(FlashVars.swf)中就可以直接获取foo、program、language变量数据。FlashVars.fla获取FlashVars参数的代码如下:

// 创建三个文本字段

_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;

字串8

foo_txt.border = true;

program_txt.autoSize = true;

program_txt.border = true;

language_txt.autoSize = true;

language_txt.border = true;

// 获取FlashVars变量

foo_txt.text = "HTML中的foo参数:" foo;

program_txt.text = "HTML中的program参数:" program;

language_txt.text = "HTML中的language参数:" language;

C、两者的有效结合

在HTML网页中使用js获取参数,然后将获取的参数作为FlashVars写入flashobject传递给swf。代码如下:

<!--

function writeflashobject(parastr) {

document.write("\n");

document.write("\n");

document.write("\n"); 字串2

document.write("\n");

document.write("\n");

document.write("\n");

document.write("");

document.write("");

}

function getparastr() {

var hrefstr,pos,parastr,para,tempstr1;

hrefstr = window.location.href;

pos = hrefstr.indexOf("?")

parastr = hrefstr.substring(pos 1);

return parastr;

}

var parastr = getparastr();

writeflashobject(parastr);

//-->

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。