User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 361,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,111 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 891 | Replies: 6 | Solved
Reply
Join Date: Feb 2008
Posts: 85
Reputation: tiger86 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
tiger86's Avatar
tiger86 tiger86 is offline Offline
Junior Poster in Training

is it possible to over write internal java script?

  #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.
I may not always be correct.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Location: Noida, India
Posts: 138
Reputation: Luckychap is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 14
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Junior Poster

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

  #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  
Join Date: Feb 2008
Posts: 85
Reputation: tiger86 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
tiger86's Avatar
tiger86 tiger86 is offline Offline
Junior Poster in Training

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

  #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.
I may not always be correct.
Reply With Quote  
Join Date: Feb 2008
Posts: 85
Reputation: tiger86 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
tiger86's Avatar
tiger86 tiger86 is offline Offline
Junior Poster in Training

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

  #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.
I may not always be correct.
Reply With Quote  
Join Date: Aug 2006
Location: Noida, India
Posts: 138
Reputation: Luckychap is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 14
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Junior Poster

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

  #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 7:51 am. Reason: Keep It Organized - plase use [code] tags
Reply With Quote  
Join Date: Feb 2008
Posts: 85
Reputation: tiger86 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
tiger86's Avatar
tiger86 tiger86 is offline Offline
Junior Poster in Training

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

  #6  
Apr 30th, 2008
It works!
I may not always be correct.
Reply With Quote  
Join Date: Feb 2008
Posts: 85
Reputation: tiger86 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
tiger86's Avatar
tiger86 tiger86 is offline Offline
Junior Poster in Training

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

  #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.
I may not always be correct.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

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

All times are GMT -4. The time now is 2:07 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC