2013-05-07 49 views
0

我是一个新手,所以轻轻地对待我。Highslide open html onload

我想在加载时打开一个Highslide html窗口。我已经看到了旧的“Highsoft”网站的解释,但无法使其工作。

这里是没有任何脚本我的测试文件,以使其开放的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> 

什么我需要做的,使Highslide窗口打开的onload以及保持可点击的链接?

祝福

杰弗里

+0

,你需要在身体标记来指定onload事件.. – 2013-05-07 09:13:38

+0

使用Highslide时,您不需要在body标签中指定onload事件。来自EarlyOut的回答来自我的评论。 – RoadRash 2013-05-07 11:45:48

回答

0

的一个好方法是使一个功能火灾时该文件已准备就绪。

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

额外信息: 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

+0

请注意,我主要是一个jQuery的家伙,但这应该至少导致你在正确的方向。你可能也想用“交互式”而不是“完整”来解雇它,但这将取决于你的需求。 – Eirinn 2013-05-07 09:22:40

2

首先,你需要使用完整Highslide脚本,而不是精简highslide与 - html.js版本。使用highslide-full.js或highslide-full.min.js(完整脚本的压缩版本)。

接下来,您的href需要一个唯一的ID:

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

ID可以是任何东西,只要它是独一无二的。

最后,在highslide.config.js文件将其添加到Highslide配置选项:如果你想打开的任何窗口的onload

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

查看此Highslide常见问题解答项目:http://www.highslide.com/forum/viewtopic.php?f = 4&t = 1882 =>第二种方法 - 如果您想打开并存在锚点...阅读有关HTML扩展器的部分。 – RoadRash 2013-05-07 11:41:07

+0

现场演示:http://jsfiddle.net/Uwxdf/ – RoadRash 2013-05-07 11:52:53

+0

非常感谢所有的建议。我现在有这个工作 – gpocock 2013-05-08 19:41:05