?
Solved

Execute JScript in FireFox

Posted on 2006-04-09
20
Medium Priority
?
1,469 Views
Last Modified: 2011-10-03
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
0
Comment
Question by:PaulCaswell
  • 10
  • 7
  • 2
  • +1
20 Comments
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 336 total points
ID: 16412496
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
 
LVL 16

Author Comment

by:PaulCaswell
ID: 16412545
>>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
 
LVL 35

Expert Comment

by:TimYates
ID: 16412576
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 16

Author Comment

by:PaulCaswell
ID: 16412593
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
 
LVL 16

Author Comment

by:PaulCaswell
ID: 16412601
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
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 164 total points
ID: 16413029
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 16413034
0
 
LVL 16

Author Comment

by:PaulCaswell
ID: 16413256
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
 
LVL 16

Author Comment

by:PaulCaswell
ID: 16413787
This gives '0':

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

What am I doing wrong?

Paul
0
 
LVL 35

Expert Comment

by:TimYates
ID: 16415055
Strange...  it gives me a number... :-/

I'm on Firefox 1.5
0
 
LVL 16

Author Comment

by:PaulCaswell
ID: 16415302
>>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
 
LVL 35

Expert Comment

by:TimYates
ID: 16415324
Works on mine :-/
0
 
LVL 3

Expert Comment

by:ndixon
ID: 16415601
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
 
LVL 16

Author Comment

by:PaulCaswell
ID: 16419841
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
 
LVL 35

Expert Comment

by:TimYates
ID: 16424317
>> 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
 
LVL 16

Author Comment

by:PaulCaswell
ID: 16429978
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
 
LVL 35

Accepted Solution

by:
TimYates earned 336 total points
ID: 16430095
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
 
LVL 16

Author Comment

by:PaulCaswell
ID: 16430253
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
 
LVL 35

Expert Comment

by:TimYates
ID: 16430329
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
 
LVL 16

Author Comment

by:PaulCaswell
ID: 16430862
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question