简体   繁体   English

如何使用js和jquery onclick从另一个HTML页面检索代码

[英]How can I retrieve code from another html page using js & jquery, onclick

So, I've noticed that when using the following code for the purposes detailed in the title, that code from settings.html appears, then disappears almost instantaneously. 因此,我注意到,将以下代码用于标题中详述的目的时,来自settings.html的代码出现了,然后几乎立即消失了。

Javascript: Javascript:

function load() {
    $("#paste").load("settings.html");
}

HTML: HTML:

<a href="" onclick="load();">Settings</a>
<div id="paste"></div>

However when using the following javascript/jquery instead, the browser freezes. 但是,当改用以下javascript / jquery时,浏览器将冻结。 (And the content does not load at all) (而且内容根本不会加载)

function load() {
  for (i = 0; i < 1;) {
    $("#paste").load("settings.html");
  }
}

What can I do to solve this? 我该怎么解决?

JavaScript Code JavaScript代码

function load() {
    $("#paste").load("settings.html");
}

HTML 的HTML

<a href="javascript:void(0);" onclick="load();">Settings</a>
<div id="paste"></div>

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

相关问题 如何使用JS从另一个页面检索图像路径? - How can I retrieve an image path from another page using JS? 如何从另一个页面更改页面的html代码? - How can I change html code of a page from another page? 如何使用 JSON 数据重定向到另一个页面 HTML onClick - How can I redirect to another page HTML onClick using JSON data 如何使用javascript将值从一个html页面传递到另一个html页面 - How can I pass values from one html page to another html page using javascript 如何使用Ajax从一个HTML页面中使用数据来检索要在另一HTML页面上使用的数据 - How to use data from one HTML page to retrieve data to be used on another HTML page using ajax 如何使用 JavaScript 或 jQuery 检索图像错误代码? - How can I retrieve image error code using JavaScript or jQuery? 如何使用html中的onclick属性从另一个网页调用一个网页的javascript函数? - How to call the javascript function of one web page from another web page using onclick attribute in html? 如何将JQuery和另一个JS文件链接到我的html? - How can I link JQuery AND another JS file to my html? 如何在 React js 中从一个 HTML 页面路由到另一个 HTML 页面? - How can i route from one HTML page to another in react js? 如何从.js中获取文本形式的javascript代码以插入html页面? - How can I get javascript code as text from .js to be inserted into an html page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM