js中showModalDialog存在的跨域问题

测试成功例子:

 

a.html:

<mce:script type="text/javascript"><!-- function function1() { var obj = new Object(); obj.name = "51js"; window.showModalDialog("b.html",obj,"dialogWidth=200px;dialogHeight=100px"); } // --></mce:script> <input value="jhlkldk" type="button" name="click" id="click" onclick="function1();">

 

b.html:(如果b.html在本地)

<mce:script type="text/javascript"><!-- function test() { var obj = window.dialogArguments; alert("您传递的参数为:"+obj.name); } // --></mce:script> <input type="button" name="hello" id="hello" value="hello" onclick="test();">

 

这种情况下,b.html页面便可以获取到传递的参数;但是,如果b.html在其他机子上,如下所示:

 

a.html调用b.html方式改变:

<mce:script type="text/javascript"><!-- function function1() { var obj = new Object(); obj.name = "51js"; window.showModalDialog("http://192.168.3.63/liwen/b.html",obj,"dialogWidth=200px;dialogHeight=100px"); } // --></mce:script> <input value="jhlkldk" type="button" name="click" id="click" onclick="function1();">

 

这种情况下b.html中就无法获取参数,这就是因为js的跨域问题所造成的。

 

 

你可能感兴趣的:(function,object,测试,input,button)