简体   繁体   English

涉及代理后,JavaScript无法正常运行

[英]Javascript doesn't function properly once proxy is involved

I have a simple code which you can find in the following link: http://jsfiddle.net/UXCb9/26/ 我有一个简单的代码,您可以在以下链接中找到: http : //jsfiddle.net/UXCb9/26/

<form name="Form1" method="post">
<!--Form data here, irrelevant.-->
<INPUT type="button" value="Watch" onclick="return move();">
</form> 
<br><iframe name="frame1" width="50%" height="50%""></iframe>

<script type="text/javascript">  
    function move() {
        document.Form1.action = "http://translation.babylon.com/"
        document.Form1.target = "frame1";    // Open in an Iframe
        document.Form1.submit();   // Submit the page with "Form1" Data
        setTimeout("move2()", 2000);
    }
</script>
<script type="text/javascript">
    var person = { name: 'Joe Blow' };  // Disregard
    function move2() {
        document.write(person.name);  //  Write text once timer is over
    }
</script>

Basically it's just a form that once clicked calls a Java function, the function submits the form into an iframe, and finally - the user receives a short message after 2 seconds(through a timer). 基本上,它只是一种形式,一旦单击即调用Java函数,该函数将表单提交到iframe中,最后-用户在2秒钟后(通过计时器)收到一条短消息。 It works fine, but once a user tries to use the code through a "surf anonymously with proxy" website such as this: http://www.superbproxy.com/browse.php?u=http%3A%2F%2Fjsfiddle.net%2FUXCb9%2F26%2F&b=4&f=norefer 它可以正常工作,但是一旦用户尝试通过“与代理匿名冲浪”网站使用代码,例如: http : //www.superbproxy.com/browse.php?u=http% 3A%2F%2Fjsfiddle 。净%2FUXCb9%2F26%2F&b = 4&F = norefer

Well, it doesn't work. 好吧,它不起作用。 I've tried the code with a couple of similar proxy websites(the above is just an example) and the result is the same. 我已经尝试了几个类似的代理网站的代码(以上仅是示例),结果是相同的。 I've tried figuring out why won't the proxy site process the Java properly but ran out of ideas. 我试图弄清楚为什么代理站点不能正确处理Java,但是用尽了所有想法。 It's important for me that my users which use proxy (there's quite a lot) won't face any problems. 对我而言,重要的是,使用代理(很多)的用户不会遇到任何问题。 Thanks in advance. 提前致谢。

The behavior will change according to the webproxy. 该行为将根据webproxy进行更改。 Some web proxies try to parse the URL's included in the Javascript code on the page however it fails when there is no semicolon at the end of the line. 某些Web代理尝试解析页面上Javascript代码中包含的URL,但是如果行末没有分号,则URL失败。

You have a missing semicolon at 您在缺少分号

document.Form1.action = "http://translation.babylon.com/"

I added a semicolon and the proxies you mentioned worked fine with the jsFiddle 我添加了分号,并且您提到的代理可以与jsFiddle一起使用

Demo: http://jsfiddle.net/UXCb9/28/ 演示: http : //jsfiddle.net/UXCb9/28/

With Proxy: http://www.superbproxy.com/browse.php?u=http://jsfiddle.net/UXCb9/28/ 使用代理: http : //www.superbproxy.com/browse.php? u= http : //jsfiddle.net/UXCb9/28/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM