> BUT.....if it works as a javascript embeded on the webpage....it should
also work as a bookmarklet too...right? My problem is that if I have a
bookmarklet encoded in a webpage, and execute it from that webpage, IT
WORKS. But if I try to install that same bookmarklet into my browser's
"favorites" and execute it from there (which is the normal procedure
for bookmarklets), it DOES NOT WORK!
Any other ideas?
ok, I finally solved the problem. There were two seperate issues (1) As
mentioned above, IE has a very small char max for bookmarklets, and one
also needs to keep in mind that a whitespace is replaced with "%20". So
once I slimmed it way down things started working. (2) For this to work
on other browsers i had to add the following line:
"netscape.security.PrivilegeManager.enablePrivileg e('UniversalBrowserRead');"
and then things started working.
One thing that I am still uneasy about is how i got around the
"same-domain security policies" issues....maybe this will pop up
later???
Thanks for everyones help. I will post the working code just for
future users, this is the more robust version....(before I slimmed it
down for the actual bookmarklet):
function parseAndRepost(dom){
conn = false;
try{
// code for IE
if (window.ActiveXObject) {
conn=new ActiveXObject('Msxml2.XMLHTTP');
}
// code for Mozilla, etc.
else if (window.XMLHttpRequest) {
try {
netscape.security.PrivilegeManager.enablePrivilege ('UniversalBrowserRead');
}
catch (e) {
alert('Permission UniversalBrowserRead denied.');
}
conn=new XMLHttpRequest();
}
}
catch(e){
conn=false;
}
if(conn) {
var myUrl='http://____some__address___';
var myStr=dom.body.innerHTML;
conn.onreadystatechange=callback;
conn.open('POST',myUrl,true);
conn.setRequestHeader('Content-type','application/x-www-form-urlencoded');
conn.setRequestHeader('Content-length',myStr.length);
conn.setRequestHeader('Connection','close');
conn.send(myStr);
}
else{
alert('Warning #3 - XMLHTTPRequest connection failed');
}
}
////////////////////////////////////////////////////////////
// This is the callback function, that is called when the "send"
returns
///////////////////////////////////////////////////////////
function callback(){
if(conn.readyState==4){
if(conn.status==200){
result=conn.responseText;
document.body.innerHTML=result;
alert('End');
conn = null;
}
else{
alert('There was a problem with the request.');
}
}
}
Thanks again! <THREAD CLOSED....but more discussion is welcome>