473,383 Members | 1,864 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,383 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 5238
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.