【发布时间】:2011-12-24 12:59:52
【问题描述】:
我正在尝试为 Opera 编写我的第一个扩展。它的快速拨号扩展。 我希望它显示一些来自网站的数据,但要访问这些数据,我需要登录。
我已经登录,opera 知道 ;-) (当我在 Opera 的地址栏中输入网站地址时,一切正常。)我希望 Opera 告诉 JS,我已登录;- )
但是当我尝试在 js 中获取该网站时,我收到了一条文本,上面写着我需要登录:
r_xmlhttp.open("GET",url,true);
//r_xmlhttp.withCredentials = 'true'; //even with that on, nothing changes.
r_xmlhttp.onreadystatechange = user_func;
r_xmlhttp.send();
我的 config.xml(那是教程中的一个;-),添加了访问源和功能 opera:share-cookies:
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" id="http://example.com/SimpleClockSD" defaultlocale="en" viewmodes="minimized">
<name short="Simple Clock">Clock Speed Dial Extension</name>
<description>This is an example Speed Dial extension showing a simple clock.</description>
<author href="http://people.opera.com/danield/">Daniel Davis</author>
<icon src="images/icon_64.png"/> <!-- Icon source: http://www.openclipart.org/detail/17552 -->
<feature name="opera:share-cookies" required="false"/>
<access origin="http://wykop.pl" subdomains="true"/>
<feature name="opera:speeddial" required="false">
<param name="url" value="http://wykop.pl"/>
</feature>
</widget>
我查看了 wireshark 的情况,我可以看出 Opera 发送的不是 JS 的 cookie,这就是为什么 JS 说我没有登录。但我希望 JS 发送与 opera 发送的相同的 cookie,理论上应该这样做,因为我添加了名为“opera:share-cookies”的功能,对吧?
我做错了什么?
【问题讨论】:
标签: javascript cookies opera opera-extension