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
LVL 16
PaulCaswellAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimYatesCommented:
You mean a bookmarklet?

ie put the following as the location of a new bookmark:

    javascript:function d(){ alert( document.title );};d();

then when you click the bookmark, it will alert you with the current page title...

Tim
0
PaulCaswellAuthor Commented:
>>You mean a bookmarklet?
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
0
TimYatesCommented:
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
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

PaulCaswellAuthor Commented:
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
0
PaulCaswellAuthor Commented:
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
0
Michel PlungjanIT ExpertCommented:
How big is it?
If it is not too big, take the script and make sure you have ; between each statement and then remove the linefeeds.
Then it is a bookmarklet
0
Michel PlungjanIT ExpertCommented:
0
PaulCaswellAuthor Commented:
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.length);' I get zero. Any ideas?

The code looks like:
"javascript:function splt(){s=document.body.innerHTML;alert(s.length)..."

Paul
0
PaulCaswellAuthor Commented:
This gives '0':

javascript:function splt(){var s=document.body.innerHTML;alert(s.length);}splt();

What am I doing wrong?

Paul
0
TimYatesCommented:
Strange...  it gives me a number... :-/

I'm on Firefox 1.5
0
PaulCaswellAuthor Commented:
>>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
0
TimYatesCommented:
Works on mine :-/
0
ndixonCommented:
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.
0
PaulCaswellAuthor Commented:
All,

I disabled all my extensions (wierd feeling) and tried it again:

javascript:function splt(){s=document.body.innerHTML;alert(s.length);}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
0
TimYatesCommented:
>> 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 :-/
0
PaulCaswellAuthor Commented:
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?
0
TimYatesCommented:
Yeah, I'm on the same version...

I just spotted if you click "Load in side bar" in the bookmark properties, it DOESN'T work, and does like you say

So uncheck that, and give it another try ;-)

Tim
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PaulCaswellAuthor Commented:
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
0
TimYatesCommented:
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
0
PaulCaswellAuthor Commented:
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.innerHTML;nOffset=s.indexOf("Points must total ");nPoinx=parseInt(s.substr(nOffset+17,4));aLizards=new Array();aEdBoxIDs=new Array();nCnt=0;for(j=0;j<document.anchors.length;j++){s=document.anchors[j].parentNode.innerHTML;n=s.indexOf('points_');sEdboxID=s.substr(n,15);n=s.indexOf('Comment from');s=s.substr(n,n+60);nNameStart=s.indexOf('>')+1;nNameEnd=s.indexOf('</');sLzrd=s.substring(nNameStart,nNameEnd);if(aLizards.toString().indexOf(sLzrd)==-1&&sLzrd!="PaulCaswell"){aEdBoxIDs[nCnt]=sEdboxID;aLizards[nCnt++]=sLzrd;};}nPoinxPerLizard=parseInt(nPoinx/aLizards.length);for(j=0;j<aLizards.length;j++){document.getElementsByName(aEdBoxIDs[j])[0].value=nPoinxPerLizard;}nAssigned=nPoinxPerLizard*aLizards.length;if(nAssigned!=nPoinx){alert('Leftover:'+(nPoinx-nAssigned)+' poinx!!!')};}splt();

Paul
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.