简体   繁体   English

从超链接加载时页面无法加载?

[英]Page not loading when loaded from an hlink?

I have made a page in javascript and calls a function in his onload, but that didn't called if its loaded from hlink, but call that function if reload the page, any help will be appreciated. 我用javascript制作了一个页面,并在他的onload中调用了一个函数,但是如果它是从hlink加载的,则不会调用它,但是如果重新加载该页面,则可以调用该函数,我们将不胜感激。

i have a function name loadbody in external Js file here is my function 我在外部Js文件中有一个函数名loadbody,这是我的函数

function loadbody(){
  alert("Get values from local storage");
}

i write this function in doument.ready() . 我在doument.ready()中编写此函数。 here is my index page 这是我的索引页

<body onload="loadbody()">
<h1> this is phonegap indexpage </h1>
</body>

Just use a onclick event in hlink tag :) 只需在hlink标记中使用onclick事件即可:)

here is your HTML page :: 这是您的HTML页面::

<!DOCTYPE html>
<html>
<head>
<title>Js </title>
<script src="script.js"></script> 
</head>
<body>
<h1> this is phonegap indexpage </h1>

<a href='http://www.google.com' onclick='loadbody();'>mylink</a>

</body>
</html>

Here is your external JS page :: 这是您的外部JS页面::

function loadbody(){
alert("Get values from local storage");
}

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

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