• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to get the javascript data after it is loaded on a page

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

i have a question on javascript. i am using a yui get utility to load a javascript file on one of my pages. my javascript file has some function in it. this loaded javascript is not visible externally. so i want to see if i can somehow get the data in the loaded javascript. I only have 1 function inside the file. since the script and functions inside are not visible outside i want to cteate a javascript object with a exactly same function inside.

to do this, i need to navigate through the functions etc inside the loaded script so that i can construct my own javascript object with all the data that is in loaded javascript. is there a way to do this?

please help.

thanks in advance
 
radha mali
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
basically, i am trying to see if i can acheive this

in my loaded js file i have this

function a(){

alert(" test");
//few more lines here
}

i want to create a java object like

myobj = new Object();
myobj.a = function(){
//SAME AS THE function a() content// in here it is alert("test") and those few lines
}

can i do this in javascript or is there any other way?

thanks
 
Sheriff
Posts: 67748
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you can just call the function within your own function, or you can assign the function to the property. Rather than waiting for a replay here, why aren't you just trying it out?
 
radha mali
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry, i did not get you. i do not have much experience with javascript but i am not sure what you meaning by assign function to a proeprty? i have 2 problems. i wanted to get the code inside the fucntion that is loaded . i tried getting it by getElemetsByTagname("script") and then did a nodeValue but i got null. i am not sure why it is like that. second..say even if i get the function data somehow how can i assign it to a object proeperty? i can do obj.propert = function(){ how do i get the code here} ..that is what i am looking for. i wanted to know if there is an api..or may be my approach is wrong..

i tried different options and since it did not work i have to post here.

thanks
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What in the world does

i tried getting it by getElemetsByTagname("script") and then did a nodeValue but i got null


mean?

It makes no sense why you are referencing a script tag with nodes.

Eric
 
Bear Bibeault
Sheriff
Posts: 67748
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

or may be my approach is wrong..


As you haven't really made what you are actually trying to do apparent, it's hard to say what approach you should be taking. What's clear us that whatever you are trying to do, your approach is off base.

So take some time to explain, using terms everyone understands, what you are trying to accomplish -- not how you are trying to accomplish it.
reply
    Bookmark Topic Watch Topic
  • New Topic