gpt4 book ai didi

javascript - "message": "Uncaught ReferenceError: myFunction is not defined"?

转载 作者:行者123 更新时间:2023-11-28 11:48:42 27 4
gpt4 key购买 nike

我正在尝试将窗口重定向为按钮值,但我可以工作

这是我的代码

<!DOCTYPE html>
<html>
<body>
<p>Click the button to change the location of the first iframe element (index 0).</p>

<button class="godd" onclick="myFunction()">Try it</button>
<br>
<br>

<iframe src="http://localhost:8005/?xform=http://127.0.0.1:8080/output_path4fff"></iframe>
<iframe src="http://localhost:8005/?xform=http://127.0.0.1:8080/output_path4fff"></iframe>

<script src="http://code.jquery.com/jquery-1.11.0.min.js">
$(document).ready(myFunction() {
var Vp = $('.godd').eq(0).text();
window.frames[0].top.location.href = 'http://' + Vp;
})
</script>
</body>
</html>

请帮忙

最佳答案

Jquery 代码应如下所示:

function myFunction()   {  /* myfunction declaration */
var Vp = $('.godd').eq(0).text();
window.frames[0].top.location.href = 'http://' + Vp ;
};
$(document).ready(function(){ /* DOM ready callback */

});

You should define your function outside DOM ready. Read $(document).ready

你的脚本标签应该是这样的:

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
//Jquery Code
</script>

关于javascript - "message": "Uncaught ReferenceError: myFunction is not defined"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41799666/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com