View Full Version : file js interaction file .js ?

07-02-2011, 04:58 PM
help me!

im have 2 file .js
file 1.js code:
document.write("<script src=2.js></script>")

file 2.js code:
var f="hello"

im want run 1.js get variable of file 2.js by 3.html but don't run!

code 3.html

<script src=1.js></script>

07-02-2011, 06:20 PM
firstly I am not sure why you need to use two separates js files to write text to an html document when you can simply place the javascript in your actual html document wrapped in <script> tags...

As to help with your issue, using document.write() will convert whatever is wrapped in the double quotes ("") into plain html...so using the script tag in the write method will not work.

To get this to work, do not try to add one js file to another js file...simply add the two separately into your html document in the head section of the page..your declared variables will then be available to both js files and the html document