Jump to content

include javascript


nasi

Recommended Posts

Hi this is my javascript file named popupwindow.js"<html><head><title>Javascript Popup</title></head><body>echo "inside script";function popup(width,height){ if(window.innerWidth){ LeftPosition =(window.innerWidth-width)/2; TopPosition =((window.innerHeight-height)/4)-50; } else{ LeftPosition =(parseInt(window.screen.width)- width)/2; TopPosition=((parseInt(window.screen.height)-height)/2)-50; } attr = 'resizable=no,scrollbars=yes,width=' + width + ',height=' + height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' + TopPosition + ''; popWin=open('', 'new_window', attr); popWin.document.write('<head><title>Test Popup</title></head>'); popWin.document.write('<body><div align=center>'); popWin.document.write('<b>Please select one of the following options</b><br><br>'); popWin.document.write('<a href="http://www.google.com">view</a><br>'); popWin.document.write('<a href="www.google.com;">Add Links</a><br>'); popWin.document.write('<a href="www.google.com;">Delete</a><br>'); popWin.document.write('</div></body></html>'); }//--><a href="java script:popup(400,200);">Generate popup</a></body></html>"and this is my html file which calls popupwindow.js"<html><head></head><script type="text/javascript" src="popupwindow.js"></script><body>echo "testing javascript";</body></html>"but the html file doesn't call the script. can you please let me know the reason?

Link to comment
Share on other sites

um...are you trying to do this with PHP or javascript?

echo

is PHP, not javascript. Anyway, given what you have, your external javascript is incorrect because it should only contain javascript. Also, I would get out of the habit of using document.write. You might want to consider reviewing the tutorials for the basics of javascript. in particular the How To and Where To chapters.http://www.w3schools.com/js/default.aspFWIW, the manner in which you posted is very confusing, with the quotes and the closing comment tag but no opening one. Consider using code tags when posting code, and just copy/paste exactly what is in your document.edit: for the record, there's a few more things worth addressing in how you are trying to do this, but first we need start with the basics. what are you trying to do anyway? Are you trying to do something with PHP instead?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...