473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to activate javascript(how to write the correct format) from html script

236 100+
Hi All,

The html page(see item a below) is calling javascript(item b below), but cant work as the page show blank. Not sure if the method of calling is wrong(in terms of default directory) or javascript is wrong.

using 127.0.0.1/htmlscript.html below to call the java script embedded in the following html script.

I am using apache server and apache server have error 304(not modified)

Been trying many methods for past 1 week...

Not sure where went wrong?

Thanks and Best Rgds,
Andrew

a) html page
=========
Expand|Select|Wrap|Line Numbers
  1. <html>  
  2.    <head> 
  3. <SCRIPT LANGUAGE="JAVASCRIPT" SRC="j_pop4.js" 
  4. TYPE="TEXT/JAVASCRIPT"> 
  5. <!-- 
  6.  
  7. //--> 
  8. </SCRIPT> 
  9.  </head>  
  10.  
  11.    <body> 
  12.    </body> 
  13. </html> 
  14.  

b) javascript
=========

Expand|Select|Wrap|Line Numbers
  1. <html>   
  2.    <head>   
  3. <TITLE>Java Popup Window Example with size, title and background colour parameters</TITLE>  
  4. <script language="JavaScript1.2" type="text/javascript">  
  5. <!-- ;  
  6. var newwindow;  
  7. var wheight = 0, wwidth = 0;  
  8.  
  9. function popitup5(url, title, iwidth, iheight, colour) {  
  10. var pwidth, pheight;  
  11.  
  12. if ( !newwindow || newwindow.closed ) {  
  13. pwidth=iwidth+30;  
  14. pheight=iheight+30;  
  15. newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10');  
  16. wheight=iheight;  
  17. wwidth=iwidth;  
  18. }  
  19.  
  20. if (wheight!=iheight || wwidth!=iwidth ) {  
  21. pwidth=iwidth+30;  
  22. pheight=iheight+90;  
  23. newwindow.resizeTo(pwidth, pheight);  
  24. wheight=iheight;  
  25. wwidth=iwidth;  
  26. }  
  27.  
  28. newwindow.document.clear();  
  29. newwindow.focus();  
  30. newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');  
  31. newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >');  
  32. newwindow.document.writeln('<\/center> <\/body> <\/html>');  
  33. newwindow.document.close();  
  34. newwindow.focus();  
  35. }  
  36.  
  37. // Routines to tidy up popup windows when page is left  
  38. // Call with an onUnload="tidy5()" in body tag  
  39.  
  40. function tidy5() {  
  41. if (newwindow && !newwindow.closed) { newwindow.close(); }  
  42. }  
  43.  
  44. // Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->  
  45. </script>  
  46.  
  47.   </head>   
  48.  
  49. <BODY onUnload="tidy5()" >   
  50.  
  51. <A HREF="javascript:popitup5('0002.jpg','Temple of Heavenly Bliss', 384, 288,'white')"><IMG SRC="0002.jpg" WIDTH="160" BORDER="0" HEIGHT="120" HSPACE="10" VSPACE="5" ALT="Temple of Heavenly Bliss" TITLE="Temple of Heavenly Bliss" ALIGN=left></A>   
  52.  
  53.  
  54.  
  55.    </body>  
  56. </html>  
  57.  
  58.  
Nov 8 '08 #1
4 5239
gits
5,390 Expert Mod 4TB
you just have to cut all the html-tags in the .js-file ... since just JavaScript code has to be in it ...

regards
Nov 8 '08 #2
happyse27
236 100+
Hi Sir,

Thanks!. I tried, but cant work... Not sure what is the sample java script format when called from html?

Is it like this below? tried before but cant work. Tried other scripts below and cant work...


Thanks and best Rgds,
Andrew

javascript
=======
Expand|Select|Wrap|Line Numbers
  1.  
  2. <TITLE>Java Popup Window Example with size, title and background colour parameters</TITLE>   
  3. <script language="JavaScript1.2" type="text/javascript">   
  4. <!-- ;   
  5. var newwindow;   
  6. var wheight = 0, wwidth = 0;   
  7.  
  8. function popitup5(url, title, iwidth, iheight, colour) {   
  9. var pwidth, pheight;   
  10.  
  11. if ( !newwindow || newwindow.closed ) {   
  12. pwidth=iwidth+30;   
  13. pheight=iheight+30;   
  14. newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10');   
  15. wheight=iheight;   
  16. wwidth=iwidth;   
  17. }   
  18.  
  19. if (wheight!=iheight || wwidth!=iwidth ) {   
  20. pwidth=iwidth+30;   
  21. pheight=iheight+90;   
  22. newwindow.resizeTo(pwidth, pheight);   
  23. wheight=iheight;   
  24. wwidth=iwidth;   
  25. }   
  26.  
  27. newwindow.document.clear();   
  28. newwindow.focus();   
  29. newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');   
  30. newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >');   
  31. newwindow.document.writeln('<\/center> <\/body> <\/html>');   
  32. newwindow.document.close();   
  33. newwindow.focus();   
  34. }   
  35.  
  36. // Routines to tidy up popup windows when page is left   
  37. // Call with an onUnload="tidy5()" in body tag   
  38.  
  39. function tidy5() {   
  40. if (newwindow && !newwindow.closed) { newwindow.close(); }   
  41. }   
  42.  
  43. // Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->   
  44. </script>   
  45.  
  46.   </head>    
  47.  
  48. <BODY onUnload="tidy5()" >    
  49.  
  50. <A HREF="javascript:popitup5('0002.jpg','Temple of Heavenly Bliss', 384, 288,'white')"><IMG SRC="0002.jpg" WIDTH="160" BORDER="0" HEIGHT="120" HSPACE="10" VSPACE="5" ALT="Temple of Heavenly Bliss" TITLE="Temple of Heavenly Bliss" ALIGN=left></A>    
  51.  
  52.  
Nov 9 '08 #3
gits
5,390 Expert Mod 4TB
have a close look at the following example:

this is the page where a script is included:

[HTML]
<html>
<head>
<script type="text/javascript" src="foo.js"/>
</head>
<body>
</body>
</html>
[/HTML]
and this is in the file foo.js:
Expand|Select|Wrap|Line Numbers
  1. alert('foo');
regards
Nov 9 '08 #4
gits
5,390 Expert Mod 4TB
i'm closing this thread to let everything go here in this thread ... since now there are to much threads spread in the forum regarding this issue.

regards
MOD
Nov 9 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Phil Powell | last post by:
I am having a potential PHP/Javascript/HTML conflict going on in my code that I simply can't resolve - been wracking my brain for a good hour over this one and have come up with no good solution. ...
4
by: Sergio del Amo | last post by:
i, I have the next html page <html> <head> <script> <!-- function insertcode() { var code ="<p> blablabal babala babababab</p><h1>here comes header</h1><span>fadfafa<a...
2
by: Per Jessen | last post by:
This is a javascript question, possibly somewhat inappropriate for this group, but here we go: (please redirect me to the right place to ask). In Microsoft Internet Explorer (5 and up) using...
2
by: sneill | last post by:
MXLogic, a Denver, Colorado based software company with 100+ employees is looking for candidates with **VERY STRONG** AJAX, Javascript, HTML, and CSS skills. Our company is building...
1
by: gkellymail | last post by:
I have a small javascript/html code below that demonstrates that problem I'm having in a larger program. I've tried all kinds of things to get it to work, but it just won't do what I want. I've...
6
by: pronerd | last post by:
Hi, I am trying to dynamically set an event handler across frames. I have no problems setting properties across frames doing something like parent.ToolMenuFrame.location.href =...
16
by: Tony Girgenti | last post by:
Hello. I just finished reading two articles about javascript here: http://msdn2.microsoft.com/en-us/library/bb332123(VS.80).aspx I tried some javascript testing in VS2005, SP1, VB , .NET 2.0,...
6
by: jim | last post by:
I am seeking a .Net component that handles CSS, Javascript, HTML and PHP editing, validation and auto-completion (intellisense would be great). I have searched Google and componentsource but have...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.