aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes how to get the javascript data after it is loaded on a page Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "how to get the javascript data after it is loaded on a page" Watch "how to get the javascript data after it is loaded on a page" New topic
Author

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

radha mali
Greenhorn

Joined: Apr 01, 2011
Posts: 9
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

Joined: Apr 01, 2011
Posts: 9
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

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?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
radha mali
Greenhorn

Joined: Apr 01, 2011
Posts: 9
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
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how to get the javascript data after it is loaded on a page
 
Similar Threads
Variables
Dumb question - variables
newbie javascript question about access rights...
Best practise to load javascript settings from server
calling functions in .js file