Opera 存储与存储更新偏好设置
我在这里已经完全困惑了很长一段时间。谁能告诉我我做错了什么?我已经设置了几个菜单,其 ID 如下所示:
<li><label for="website">Select Website:</label>
<select name="website" id="website" />
<option value="http://www.site1.com">Website 1</option>
<option value="http://www.site2.com">Website 2</option>
<option value="http://www.site3.com">Website 3</option>
</select>
</li>
并使用 javascript 设置如下:
var sd = opera.contexts.speeddial;
var weburl = document.getElementById( 'website' );
weburl.addEventListener( 'change', function() {
sd.url = this.value;
}, false );
if ( sd.url ) {
weburl.value = sd.url;
}
试图在单击时更改 Opera 快速拨号 URL 的目标。但这不起作用。我有一种感觉,我必须在主index.html中添加一些js,但我不太确定。
I've been completely stumped for quite a while here. Could anyone tell me what I'm doing wrong? I have set several menus with the IDs like so:
<li><label for="website">Select Website:</label>
<select name="website" id="website" />
<option value="http://www.site1.com">Website 1</option>
<option value="http://www.site2.com">Website 2</option>
<option value="http://www.site3.com">Website 3</option>
</select>
</li>
and with javascript like so:
var sd = opera.contexts.speeddial;
var weburl = document.getElementById( 'website' );
weburl.addEventListener( 'change', function() {
sd.url = this.value;
}, false );
if ( sd.url ) {
weburl.value = sd.url;
}
In an attempt to change the destination of the Opera Speed Dial's URL when one clicks on it. But it does not work. I have a feeling that I've got to add some js to the main index.html, but I'm not so sure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要记住代码运行的顺序。在上面的代码中,
if ( sd.url ) {
部分立即运行,但设置 sd.url 的代码将仅当您在 SELECT 元素中选择某些内容时才运行。因此,当 if - 部分运行时,sd.url 还不会被设置。
这有帮助吗?
I think you need to keep in mind what order the code will run in.. In the code above, the
if ( sd.url ) {
part runs immediately, but the code that sets sd.url will only run when you choose something in the SELECT element. Hence, when the if - part runs, sd.url will not be set yet.
Does that help?