简体   繁体   English

Highslide打开html onload

[英]Highslide open html onload

I am a newbie so treat me gently. 我是新手,所以要温柔地对待我。

I want to open an Highslide html window on load. 我想在加载时打开一个Highslide html窗口。 I have seen an explanation on the old "Highsoft" site but cannot make it work. 我已经在旧的“Highsoft”网站上看到了解释,但无法使其发挥作用。

Here is my test file without any script to make it open onload: 这是我的测试文件没有任何脚本使其打开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>

What do I need to do to make the Highslide window open onload as well as keeping the clickable link? 我需要做什么才能使Highslide窗口打开并保持可点击链接?

Best Wishes 最好的祝愿

Geoffrey 杰弗里

First, you need to use the full Highslide script, not the stripped-down highslide-with-html.js version. 首先,您需要使用完整的Highslide脚本,而不是使用精简版的highslide-with-html.js版本。 Use highslide-full.js or highslide-full.min.js (a compressed version of the full script). 使用highslide-full.js或highslide-full.min.js(完整脚本的压缩版本)。

Next, your href needs a unique ID: 接下来,您的href需要一个唯一的ID:

<a href="#" id="image1" onclick="return hs.htmlExpand....

The ID can be anything, as long as it's unique. ID可以是任何东西,只要它是唯一的。

Finally, add this to the Highslide config options in your highslide.config.js file: 最后,将其添加到highslide.config.js文件中的Highslide配置选项:

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

A good way would be to make a function fire when the document is ready. 一个好方法是在文档准备好时激活函数。

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

Extra information: Javascript - How to detect if document has loaded (IE 7/Firefox 3) http://www.w3schools.com/jsref/prop_doc_readystate.asp http://www.w3schools.com/jsref/met_win_open.asp 额外信息: Javascript - 如何检测文档是否已加载(IE 7 / Firefox 3) http://www.w3schools.com/jsref/prop_doc_readystate.asp http://www.w3schools.com/jsref/met_win_open.asp

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

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