PaulCaswell
asked on
Execute JScript in FireFox
All,
I have a JScript tool I use in Explorer on web pages. I can drag the tool from my favorites onto the page and it is performed on the page contents.
How can I do the equivalen in FireFox?
Paul
I have a JScript tool I use in Explorer on web pages. I can drag the tool from my favorites onto the page and it is performed on the page contents.
How can I do the equivalen in FireFox?
Paul
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ahhh... now it gets tricky...
I never found a way of doing this :-(
I only managed to execute commands less than 1000 chars (or something) in length, due to restrictions in URL length (under IE)
It *may* be possible to add a link to your script into the page, then execute commands from the script, but I would imagine you'd hit all sorts of cross-site scripting security issues...
What is it you're trying to do? Maybe something already exists to do it?
Tim
I never found a way of doing this :-(
I only managed to execute commands less than 1000 chars (or something) in length, due to restrictions in URL length (under IE)
It *may* be possible to add a link to your script into the page, then execute commands from the script, but I would imagine you'd hit all sorts of cross-site scripting security issues...
What is it you're trying to do? Maybe something already exists to do it?
Tim
ASKER
Its actually a points splitter I found. It was written by DanRollins. Essentially, you hit the 'Split Points' link on your question and then invoke the script. It walks through the question building a list of all contributors and distributes the points equally among them. I doubt if thats possible in one line.
Obviously there's no chance of embedding it in the page.
I used to use Explorer but since I've moved over to FireFox I'm not going back :-) In explorer you just drop the script on the page and it executes.
Paul
Obviously there's no chance of embedding it in the page.
I used to use Explorer but since I've moved over to FireFox I'm not going back :-) In explorer you just drop the script on the page and it executes.
Paul
ASKER
I am not familliar with JavaScript but something like:
javascript:function d(){ execute( "C:\Tools\MyTool.js" );};d();
would be the sort of thing I suspect I am looking for.
Paul
javascript:function d(){ execute( "C:\Tools\MyTool.js" );};d();
would be the sort of thing I suspect I am looking for.
Paul
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Looks like progress!
It doesnt work for me! I've traced it back to extracting the inner HTML. If I do 's=document.body.innerHTML ;alert(s.l ength);' I get zero. Any ideas?
The code looks like:
"javascript:function splt(){s=document.body.inn erHTML;ale rt(s.lengt h)..."
Paul
It doesnt work for me! I've traced it back to extracting the inner HTML. If I do 's=document.body.innerHTML
The code looks like:
"javascript:function splt(){s=document.body.inn
Paul
ASKER
This gives '0':
javascript:function splt(){var s=document.body.innerHTML; alert(s.le ngth);}spl t();
What am I doing wrong?
Paul
javascript:function splt(){var s=document.body.innerHTML;
What am I doing wrong?
Paul
Strange... it gives me a number... :-/
I'm on Firefox 1.5
I'm on Firefox 1.5
ASKER
>>I'm on Firefox 1.5
1.5.0.1!
Oddly though, after it executes, my Bookmarks sidebar goes blank! Could I have an extension that's interfering?
Happens on other sites too!
Paul
1.5.0.1!
Oddly though, after it executes, my Bookmarks sidebar goes blank! Could I have an extension that's interfering?
Happens on other sites too!
Paul
Works on mine :-/
this is a little out of your topic area, but...
JScript has descrete differences to Javascript JScript - JScript is microsoft's own take on the scripting language, and although for the most part it is compatable in other browsers, it contains features that are only available in IE.
JScript has descrete differences to Javascript JScript - JScript is microsoft's own take on the scripting language, and although for the most part it is compatable in other browsers, it contains features that are only available in IE.
ASKER
All,
I disabled all my extensions (wierd feeling) and tried it again:
javascript:function splt(){s=document.body.inn erHTML;ale rt(s.lengt h);}splt() ;
Still showing '0'. Any more thoughts?
Is there any other way of getting the contents of the current page?
I keep feeling that the disappearance of the bookmarks sidebar after execution is important. What might that mean?
Paul
I disabled all my extensions (wierd feeling) and tried it again:
javascript:function splt(){s=document.body.inn
Still showing '0'. Any more thoughts?
Is there any other way of getting the contents of the current page?
I keep feeling that the disappearance of the bookmarks sidebar after execution is important. What might that mean?
Paul
>> I keep feeling that the disappearance of the bookmarks sidebar after execution is important. What might that mean?
It's odd, because mine doesn't disappear :-/
It's odd, because mine doesn't disappear :-/
ASKER
A technique I often use to track down bugs is to try to discover how I would do it deliberately so:
How would you make the sidebar go blank (if its there) and both appear AND be blank if its not there, using JScript?
Paul
P.S. Could this be a FF Version issue? As I said, I have 1.5.0.1. Is that the same as yours? Are you running Windows XP-SP2 like me?
How would you make the sidebar go blank (if its there) and both appear AND be blank if its not there, using JScript?
Paul
P.S. Could this be a FF Version issue? As I said, I have 1.5.0.1. Is that the same as yours? Are you running Windows XP-SP2 like me?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow! I didnt spot that! Good catch! That explains the whole thing! Even the blanking of the sidebar!
My fragment now gives me 61481 for this page so I should be able to resurrect the original and test it.
I think I'll split the points here :-)
Paul
My fragment now gives me 61481 for this page so I should be able to resurrect the original and test it.
I think I'll split the points here :-)
Paul
yay! yeah, now the code mplungjan gave here http:Q_21807403.html#16413034 should work fine :-)
i dont use the sidebar... that's my excuse anyway ;-)
good luck!
Tim
i dont use the sidebar... that's my excuse anyway ;-)
good luck!
Tim
ASKER
It worked! Thanks all!
Here's the code in case anyone wants it! I added a bit to the original to not give me any points and a few other bits.
javascript:function splt(){s=document.body.inn erHTML;nOf fset=s.ind exOf("Poin ts must total ");nPoinx=parseInt(s.subst r(nOffset+ 17,4));aLi zards=new Array();aEdBoxIDs=new Array();nCnt=0;for(j=0;j<d ocument.an chors.leng th;j++){s= document.a nchors[j]. parentNode .innerHTML ;n=s.index Of('points _');sEdbox ID=s.subst r(n,15);n= s.indexOf( 'Comment from');s=s.substr(n,n+60); nNameStart =s.indexOf ('>')+1;nN ameEnd=s.i ndexOf('</ ');sLzrd=s .substring (nNameStar t,nNameEnd );if(aLiza rds.toStri ng().index Of(sLzrd)= =-1&&sLzrd !="PaulCas well"){aEd BoxIDs[nCn t]=sEdboxI D;aLizards [nCnt++]=s Lzrd;};}nP oinxPerLiz ard=parseI nt(nPoinx/ aLizards.l ength);for (j=0;j<aLi zards.leng th;j++){do cument.get ElementsBy Name(aEdBo xIDs[j])[0 ].value=nP oinxPerLiz ard;}nAssi gned=nPoin xPerLizard *aLizards. length;if( nAssigned! =nPoinx){a lert('Left over:'+(nP oinx-nAssi gned)+' poinx!!!')};}splt();
Paul
Here's the code in case anyone wants it! I added a bit to the original to not give me any points and a few other bits.
javascript:function splt(){s=document.body.inn
Paul
ASKER
So it is possible!
I have a tool in C:\Tools\MyTool.js. What do I change my bookmarklet (how cute) to so it executes instead of opening?
Paul