Load script with each page.

D

Dave Fowler

I have a simple script that hides an image when you click on it. I
think it would be cool to have that functionality for all pages I
visit.

Is there a way to set my browser settings to automatically load that
script with each page I visit?
 
D

Dave Fowler

Dave Fowler said the following on 9/1/2007 5:56 PM:



To do it automatically, I doubt you could do in IE without coding your
own plugin (or finding an existing one). You could probably do it easily
in Gecko based browsers.

An easy alternative is to take your script and put it in a .js file and
make sure all the variable names are as unique as possible to keep from
causing a conflict, write a routine to apply an onclick event to each
and every image in the current page, then use a bookmarklet to inject
that script into the current page.

Post the script and let's see what can be done.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/


Randy, Thanks for your help. The script is fairly simple (but uses
JQuery) Its actually part of the JQuery tutorial


<!-- loads thethe jquery script -->
<script type="text/javascript" src="http://localhost/media/base/
jquery.js"></script>

<!-- slow hide images function -->
<script type="text/javascript">
$(document).ready(function(){
// Your code here

$("img.profile").click(function(){
$(this).hide("slow");
return false;
});


});

</script>


I could use a bookmarklet, and am probably going to have to. I was
wondering however if you could automatically inject a script without
having to click the bookmark.
 
D

Dave Fowler

Dave said:
[...] The script is fairly simple (but uses
JQuery) Its actually part of the JQuery tutorial

Sorry, this is not a support forum for junk code such as jQuery.
Tryhttp://docs.jquery.com/Discussionfor bad advice instead.

PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee

Thomas,

Didn't mean for it to be about Jquery or my junk code. Randy asked me
to post my example code so I did. The example is really
unimportant.

I'm simply wondering if anyone knows of a way to set any browser to
automatically load a script with each page it renders. It would
enable you to add some javascript features (like hiding images) to
every page you visit.

Does anyone know if this is possible, or know that it is not possible?

Thank you
 
T

Thomas 'PointedEars' Lahn

Dave said:
I'm simply wondering if anyone knows of a way to set any browser to
automatically load a script with each page it renders. It would
enable you to add some javascript features (like hiding images) to
every page you visit.

Does anyone know if this is possible, or know that it is not possible?

If you think about it, it cannot be possible. That follows alone from the
fact that there are browsers (let alone Web user agents) that do not support
client-side J(ava)Script/ECMAScript.

You should specify your problem including the requirements for the execution
environment of your code instead of asking vaguely for a solution to the
problem introduced by your approach for a solution to your problem.


PointedEars
 
A

Aaron Saray

I have a simple script that hides an image when you click on it. I
think it would be cool to have that functionality for all pages I
visit.

Is there a way to set my browser settings to automatically load that
script with each page I visit?

If you're using Firefox, try searching for 'greasemonkey' extension.
This allows you to program javascript to be executed on certain (or
all) pages automatically. I'm not sure of a program for this
functionality in IE.
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
legroups.com>, Sat, 1 Sep 2007 23:50:09, Dave Fowler
Didn't mean for it to be about Jquery or my junk code. Randy asked me
to post my example code so I did. The example is really
unimportant.

Thomas is sociologically disturbed; don't let him upset you.

He also has not thought about the difference between "any" and "every".
 
D

Dave Fowler

If you're using Firefox, try searching for 'greasemonkey' extension.
This allows you to program javascript to be executed on certain (or
all) pages automatically. I'm not sure of a program for this
functionality in IE.

Thanks. Will do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,157
Messages
2,570,879
Members
47,413
Latest member
KeiraLight

Latest Threads

Top