How to access a variable declared in one javascript in another javascript ?

Please help me with the code.

Thanks in advance.

Are the two javascripts in the same web page?

the two scripts are in different pages... any solution ???

Are both pages in the same domain? browsers block cross domain scripting by default.

You could pass a variable on the query string.

In your first html it would look something like this.

<a href="#" id="mylink" title="Home">Click Me</a>
    var myvar = "test";
	document.getElementById("mylink").href="" + myvar;

And your receiving html would look something like this.

var loc = location.href;
loc = loc.toString();
var arr = loc.split("?");
var myvar = arr[1];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.