Closed Thread Icon

Topic awaiting preservation: Javascript on link? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=7868" title="Pages that link to Topic awaiting preservation: Javascript on link? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Javascript on link? <span class="small">(Page 1 of 1)</span>\

 
StereoType
Bipolar (III) Inmate

From: the plushdjungle
Insane since: Oct 2001

posted posted 10-04-2001 18:59

Hi there! This is my first post on this forum, but I have been watching it for quite a while now.
My question is if anyone knows if it's possible to attach a javascript to a link? I am trying to do a -alizer that changes some defined words into something else, using javascript.
Something like "if(document.all){document.body.innerHTML=document.body.innerHTML.replace('Some word','Something else')}"
Is it possible to run that script on another page? I know that the most -alizers is built in asp, but I don't know something about asp, so...

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-04-2001 19:31

Hmm.... I'm a little confused on what you are trying to do here.

But generally there are 2 ways to attach JS to a link
<a href="javascript:your code here"> That's one method. The other way is with the onClick event.

<a href="#" onClick="your code here"> The "#" keeps the link from going anywhere.



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

StereoType
Bipolar (III) Inmate

From: the plushdjungle
Insane since: Oct 2001

posted posted 10-04-2001 19:34

No, I mean something like this: (this only changes the word google on the page where the button is)

code:
<html>
<head>
<script language="JavaScript">
function ChangeWords()
{
location.replace('http://www.google.com');
if(document.all){document.body.innerHTML=document.body.innerHTML.replace('Google','Snooble')}
}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<INPUT type=button onClick="ChangeWords();" name=MyLittleButton VALUE="SnoogleGoogle">

</body>
</html>



[This message has been edited by StereoType (edited 10-04-2001).]

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-04-2001 19:39

hokay now I get it.

What you can do is open the window with JS

daWin = window.open("location.html','mywin','menubar,toolbar,location,directories,status,scrollbars,resizable,dependent');

then you can access the HTML by name

dawin.document.body.innerHTML.replace('word','WORD');





:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

StereoType
Bipolar (III) Inmate

From: the plushdjungle
Insane since: Oct 2001

posted posted 10-04-2001 20:00

Oki, Ive done this after bitdamaged's example. It SHOULD work, but it does'nt. What's wrong?

code:
<html>
<head>
<script language="JavaScript">
function ChangeWords()
{
var address = "http://www.google.com";
var toolbar = 1;
var adressbar = 1;
var directories = 1;
var statusbar = 1;
var menubar = 1;
var scrollbar = 1;
var resize = 1;
var bredd;
var hojd;
var option = "toolbar=" + toolbar + ",location=" + adressbar + ",directories="
+ directories + ",status=" + statusbar + ",menubar=" + menubar + ",scrollbars="
+ scrollbar + ",resizable=" + resize + ",width=" + bredd + ",height=" + hojd;
var win3 = window.open("", "what_I_want", option);
var win4 = window.open(address, "what_I_want");
win4.document.body.innerHTML.replace('Google','Hallå!')
}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<INPUT type=button onClick="ChangeWords();" name=MyLittleButton VALUE="SnoogleGoogle">

</body>
</html>



mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 10-04-2001 21:37

For security reasons, you can't change content of pages that didn't originate from your web server (IE will throw "Access is denied" error)...

StereoType
Bipolar (III) Inmate

From: the plushdjungle
Insane since: Oct 2001

posted posted 10-04-2001 22:15

But how does the ASP-lizers work then? Does anyone have an ASP -alizer file to show me? I can never see the actual asp-file because they just redirect or something....

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 10-04-2001 22:51

What's ASP-lizers? Do you refer to some ASP script or something else?

Dark
Neurotic (0) Inmate
Newly admitted
posted posted 10-05-2001 04:40

Yeah I have read about ASP-lizers
but evertime I do it it gives me a
"Access is denied" like maX said.

Nimraw
Paranoid (IV) Inmate

From: Styx
Insane since: Sep 2000

posted posted 10-05-2001 14:07

I guess that could be one of these Smurfalizer

StereoType
Bipolar (III) Inmate

From: the plushdjungle
Insane since: Oct 2001

posted posted 10-05-2001 14:50

Nimeaw: yeah! I'ts something like that i want to do...

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-05-2001 19:22

Thats something done with server side scripting. Basically in most languages you can do an HTTP_GET and download the source code, change it and then display the results.





:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 10-05-2001 20:18

As said above, this is done on the server-side (it can't be done on the client-side with JavaScript). And generally, this isn't very easy. Fetching file from remote server is only thing that's easy here. Now, besides words that you want to change, you *must* change all relative links (<IMG> tags, <A> tags, everything with SRC parameter) so that they point to the correct address (you should add address of the site from where you're fetching remote file) and this isn't very easy, because there are many different combinations how people can write HTML code, so you'll have to use (or write your own) HTML parser, that will parse all HTML tags and modify appropriate tags...

StereoType
Bipolar (III) Inmate

From: the plushdjungle
Insane since: Oct 2001

posted posted 10-05-2001 21:39

well, thanks all for your help, but I really suck at server side scripting so I give up for now and I will try it again when I've learnt some sss-languge...

« BackwardsOnwards »

Show Forum Drop Down Menu