is it possible to over write internal java script?

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Feb 2008
Posts: 469
Reputation: tiger86 is an unknown quantity at this point 
Solved Threads: 10
tiger86's Avatar
tiger86 tiger86 is offline Offline
Posting Pro in Training

is it possible to over write internal java script?

 
0
  #1
Apr 23rd, 2008
Is it possible to overwrite internal javascript? I am working for a non profit as an internship and they want to escape a template that almost all of the non profits in that organization have to use, the catch is the template is written in Javascript if it is possible to over ride it please tell me as I really need to know ASAP.
If I helped you I would appreciate it if you would give me some reputation.
Follow the new Social Network Planet Zuda On twitter. Planet Zuda should go live sometime in 2010.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: is it possible to over write internal java script?

 
0
  #2
Apr 24th, 2008
my be this would(i have not tired it). Javascript code are written in <script></script> tags. So search these tags in the document by using: var sTag = document.getElementsByTagName("script"). This will give u an array of script tags. Now over write them by using sTag[0].innerHTML = "your javascript code";


If this work please let me know?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 469
Reputation: tiger86 is an unknown quantity at this point 
Solved Threads: 10
tiger86's Avatar
tiger86 tiger86 is offline Offline
Posting Pro in Training

Re: is it possible to over write internal java script?

 
0
  #3
Apr 24th, 2008
Originally Posted by Luckychap View Post
my be this would(i have not tired it). Javascript code are written in <script></script> tags. So search these tags in the document by using: var sTag = document.getElementsByTagName("script"). This will give u an array of script tags. Now over write them by using sTag[0].innerHTML = "your javascript code";


If this work please let me know?
I am sorry I do not completly understand, are you saying to look in the edocument for the code you listed? If so the code isn't there if you mean something else please pm me or post.
If I helped you I would appreciate it if you would give me some reputation.
Follow the new Social Network Planet Zuda On twitter. Planet Zuda should go live sometime in 2010.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 469
Reputation: tiger86 is an unknown quantity at this point 
Solved Threads: 10
tiger86's Avatar
tiger86 tiger86 is offline Offline
Posting Pro in Training

Re: is it possible to over write internal java script?

 
0
  #4
Apr 29th, 2008
Originally Posted by tiger86 View Post
I am sorry I do not completly understand, are you saying to look in the edocument for the code you listed? If so the code isn't there if you mean something else please pm me or post.
Okay I have searched the whole javascript and they do not use the var command at all they use javascript in a odd way just for images. If there is a way to overwrite it I would be happy and so would my boss.
If I helped you I would appreciate it if you would give me some reputation.
Follow the new Social Network Planet Zuda On twitter. Planet Zuda should go live sometime in 2010.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: is it possible to over write internal java script?

 
0
  #5
Apr 30th, 2008
Hi tiger86, if u can explain ur problem little bit more, i want to know what exactly u want to do.

var is not a command but a way to declare a variable in javascript.

I am explaining my prev. post again, if u still did not get ur problem solved, explain ur problem in detail.

first i want to tell u what i understand from ur post: You want to overwrite the javacript at run-time. if this is correct then my post will help u otherwise explain me ur problem. here is want i explained in prev post. for example u have a page:

  1. <html>
  2. <head></head>
  3.  
  4. <body>
  5. <script>
  6. function myfunct() {
  7. //do something
  8. }
  9. </script>
  10.  
  11. </body>
  12. </html>


if u want to change js code in above page,
this a js code todo that :

var tags = document.getElementsByTagName("script");

//Now changing the js code
tags[0].innerHTML = "your new js code should be written here as a string";

again i had not tested it. please let me know how it works?
Last edited by peter_budo; Apr 30th, 2008 at 8:51 am. Reason: Keep It Organized - plase use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 469
Reputation: tiger86 is an unknown quantity at this point 
Solved Threads: 10
tiger86's Avatar
tiger86 tiger86 is offline Offline
Posting Pro in Training

Re: is it possible to over write internal java script?

 
0
  #6
Apr 30th, 2008
It works!
If I helped you I would appreciate it if you would give me some reputation.
Follow the new Social Network Planet Zuda On twitter. Planet Zuda should go live sometime in 2010.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 469
Reputation: tiger86 is an unknown quantity at this point 
Solved Threads: 10
tiger86's Avatar
tiger86 tiger86 is offline Offline
Posting Pro in Training

Re: is it possible to over write internal java script?

 
0
  #7
Apr 30th, 2008
the code luckychap posted works but I would not suggest using it unless it is your own website and you are not connected to a national website.
If I helped you I would appreciate it if you would give me some reputation.
Follow the new Social Network Planet Zuda On twitter. Planet Zuda should go live sometime in 2010.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: sozeran is an unknown quantity at this point 
Solved Threads: 0
sozeran sozeran is offline Offline
Newbie Poster

A problem with script overwriting

 
0
  #8
Nov 10th, 2009
Ok, and what if we have a code like this?
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script src="example.js" type="text/javascript"></script>
In this case, how can we replace the code loaded with example.js?

Let me be more informative. There is this issue on one site - the script it loads via src attribute in script tag is cut down by the server, and instead of having a 362kb successfully loaded script, I've something like 160kb cut one. So I'm trying to write a Greasemonkey userscript, which can overwrite the cut down script with code that it has in itself. For now, I'm not having any success with this problem. Can anyone help me with this?
Last edited by sozeran; Nov 10th, 2009 at 2:24 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz
 
0
  #9
Nov 11th, 2009
As I have explained how to get <script> tags. Say we have an array of tags 'scripts'.

  1. var orginalSrc = "example.js", newSrc = "new.js";
  2. // Looping through all the tags
  3. for(var i = 0; i < scripts.length; i++) {
  4. if(scripts[i].src == originalSrc) {
  5. scripts[i].src = newSrc;
  6. break;
  7. }
  8. }

Is that what u r looking for?
Last edited by Luckychap; Nov 11th, 2009 at 11:40 am.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: sozeran is an unknown quantity at this point 
Solved Threads: 0
sozeran sozeran is offline Offline
Newbie Poster
 
0
  #10
Nov 11th, 2009
Originally Posted by Luckychap View Post
As I have explained how to get <script> tags. Say we have an array of tags 'scripts'.

  1. var orginalSrc = "example.js", newSrc = "new.js";
  2. // Looping through all the tags
  3. for(var i = 0; i < scripts.length; i++) {
  4. if(scripts[i].src == originalSrc) {
  5. scripts[i].src = newSrc;
  6. break;
  7. }
  8. }

Is that what u r looking for?
Will it redefine all the functions introduced in the old script?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum


Views: 2060 | Replies: 9
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC