高幻灯片打开html onload



我是个新手,请对我温柔点。

我想在加载时打开一个Hililide html窗口。我在旧的"Hilioft"网站上看到了一个解释,但无法使其工作。

这是我的测试文件,没有任何脚本,使其打开onload:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Open on load - test</title>
<script type="text/javascript" src="highslide/highslide-with-html.js"></script>
<script type="text/javascript" src="highslide/highslide.config.js" charset="utf-       8"></script>
<link rel="stylesheet" type="text/css" href="highslide/highslide.css" />
</head>
<body>
<div>
<a href="#" onclick="return hs.htmlExpand(this, { 
        width: 400, creditsPosition: 'bottom left', 
        headingText: 'Stoke Gabriel Boating Association',     wrapperClassName: 'titlebar' } )">Inline HTML</a>
<div class="highslide-maincontent">
    <h3>Next Sailing Event</h3>
    The next sailing event will take place on June 23.
</div>
</div>
</body>
</html>

我需要做些什么来使Hililide窗口在加载时打开,并保持可点击的链接?

祝福杰弗里

首先,您需要使用完整的Hililide脚本,而不是经过精简的Hililide -with-html.js版本。使用hililide-full.js或hililide-full.min.js(完整脚本的压缩版本)。

接下来,你的href需要一个唯一的ID:
<a href="#" id="image1" onclick="return hs.htmlExpand....

ID可以是任何东西,只要它是唯一的。

最后,将此添加到Hililide .config.js文件中的Hililide配置选项中:

hs.addEventListener(window, "load", function() {
document.getElementById('image1').onclick();
});
hs.addEventListener(document, "ready", function() {
document.getElementById('image1').focus();
});

一个好的方法是在文档准备好时触发一个函数。

if (document.readyState === "complete") { window.open(URL,name,specs,replace) }

额外信息:如何检测文档是否已加载(IE 7/Firefox 3)http://www.w3schools.com/jsref/prop_doc_readystate.asphttp://www.w3schools.com/jsref/met_win_open.asp

最新更新