Rclick menuext fails with internet explorer
i'm trying to get the url and title of any website with this javascript we wrote. i made the javascript in a .HTM and get it from out my regedit in the menuExt. like file://C:\Users\lala\script.htm
here's the script
<script type="text/javascript" defer>
javascript:{var jolExt={url:"http://example.com/script_container.php?id=¬e=",submit:function(a){var b=jolExt.base64.encode(jolExt.strip(document.getElementsByTagName("title")[0].innerHTML));var d=jolExt.base64.encode(jolExt.strip(location.href));
window.open(jolExt.url+d+"¬e="+b,"","width=380,height=335")},submitToOtherJol:function(){jolExt.submit(true)},submitToJol:function(){jolExt.submit(false)},strip:function(a){return a.replace(/ {2,}/g," ").replace(/^ +/g,"").replace(/ +$/g,"")},base64:{_0:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(a){var b="";var d,c,h,j,i,f,g;var e=0;a=jolExt.base64._1(a);while(e<a.length){d=a.charCodeAt(e++);c=a.charCodeAt(e++);h=a.charCodeAt(e++);j=d>>2;i=((d&3)<<4)|(c>>4);f=((c&15)<<2)|(h>>6);g=h&63;if(isNaN(c)){f=g=64}else if(isNaN(h)){g=64}b=b+this._0.charAt(j)+this._0.charAt(i)+this._0.charAt(f)+this._0.charAt(g)}return b},decode:function(a){var b="";var d,c,h;var j,i,f,g;var e=0;a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(e<a.length){j=this._0.indexOf(a.charAt(e++));i=this._0.indexOf(a.charAt(e++));f=this._0.indexOf(a.charAt(e++));g=this._0.indexOf(a.charAt(e++));d=(j<<2)|(i>>4);c=((i&15)<<4)|(f>>2);h=((f&3)<<6)|g;b=b+String.fromCharCode(d);if(f!=64){b=b+String.fromCharCode(c)}if(g!=64){b=b+String.fromCharCode(h)}}b=jolExt.base64._2(b);return b},_1:function(a){a=a.replace(/\r\n/g,"\n");var b="";for(var d=0;d<a.length;d++){var c=a.charCodeAt(d);if(c<128){b+=String.fromCharCode(c)}else if((c>127)&&(c<2048)){b+=String.fromCharCode((c>>6)|192);b+=String.fromCharCode((c&63)|128)}else{b+=String.fromCharCode((c>>12)|224);
b+=String.fromCharCode(((c>>6)&63)|128);b+=String.fromCharCode((c&63)|128)}}return b},_2:function(a){var b="";var d=0;var c=c1=c2=0;while(d<a.length){c=a.charCodeAt(d);if(c<128){b+=String.fromCharCode(c);d++}else if((c>191)&&(c<224)){c2=a.charCodeAt(d+1);b+=String.fromCharCode(((c&31)<<6)|(c2&63));d+=2}else{c2=a.charCodeAt(d+1);c3=a.charCodeAt(d+2);b+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));d+=3}}return b}}};jolExt.submitToJol();}
when i'm using开发者_StackOverflow my add-on i made i only get the path i set on the regedit in the menuExt. Does any1 know's how to solve this. i alraidy tried to putt the full javascript in the string value but it didn't help.
so in short language, i am asking the url but i get the path of my regedit editor in the menuExt. and i need the url of the parent site and the title of the parent site.
Plz help me :)
Regards,
Freezingmoon
The problem is that the document
instance in your script is the MenuExt script's document. What you need is the document
from which the script was called.
To get this use the external.menuArguments
object. This contains the window
of the callee. Consider this simple MenuExt script
<script type="text/javascript">
// Get callee's 'window' object
var win = external.menuArguments;
// Get the callee's 'document' object.
var doc = win.document;
// Get the callee's object which invoked this
// (aka: what you right-clicked on)
var src = win.event.srcElement;
// Spit back page title and URL
alert('Viewing ' + doc.title + ' at ' + win.location +
'. You clicked on ' + src + '.');
</script>
To get the item right-clicked on, use external.menuArguments.event.srcElement
, as shown above.
精彩评论