473,657 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to activate javascript file from html page

236 New Member
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.  
  15.  
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. 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. newwindow.document.clear(); 
  27. newwindow.focus(); 
  28. newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>'); 
  29. newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >'); 
  30. newwindow.document.writeln('<\/center> <\/body> <\/html>'); 
  31. newwindow.document.close(); 
  32. newwindow.focus(); 
  33.  
  34. // Routines to tidy up popup windows when page is left 
  35. // Call with an onUnload="tidy5()" in body tag 
  36.  
  37. function tidy5() { 
  38. if (newwindow && !newwindow.closed) { newwindow.close(); } 
  39.  
  40. // Based on JavaScript provided by Peter Curtis at www.pcurtis.com --> 
  41. </script> 
  42.  
  43.   </head>  
  44.  
  45. <BODY onUnload="tidy5()" >  
  46.  
  47. <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>  
  48.  
  49.  
  50.  
  51.    </body> 
  52. </html> 
  53.  
  54.  
Nov 8 '08 #1
17 2957
gits
5,390 Recognized Expert Moderator Expert
you may find your answer here ... in the JavaScript forum.

regards
Nov 8 '08 #2
David Laakso
397 Recognized Expert Contributor
you may find your answer here ... in the JavaScript forum.

regards
And a doctype will be needed (if you intend to support any version of Internet Explorer).
Nov 8 '08 #3
happyse27
236 New Member
Hi Sir,

Read the java weblink you gave and ,

Is it something like that below? tried many times and different ways, used html to activate javascript and it did not work. and used html to activate java embedded in html page, but cant work.

Thanks and Best Rgds,
Andrew

HTML
====
Expand|Select|Wrap|Line Numbers
  1.  
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
  3.  
  4. <html> 
  5.    <head>
  6. <SCRIPT LANGUAGE="JAVASCRIPT" SRC="j_pop4.js"
  7. TYPE="TEXT/JAVASCRIPT">
  8. <!--
  9.  
  10. //-->
  11. </SCRIPT>
  12.  </head> 
  13.  
  14.    <body>
  15.    </body>
  16. </html>
  17.  
  18.  

JAVAscript that is activated
=============== =====
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.  
  47.  
  48.  
  49. <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> 
  50.  
  51.  
  52.  
  53. #The code can be copied and pasted. If you copy by hand beware as it is impossible to tell 2x single quotes '' from a double quotes " in many proportion spaced character sets (fonts).
  54.  
  55.  
Nov 9 '08 #4
happyse27
236 New Member
Hi Sir,

Something is missing and I tried many different ways and means including alert and still cant work. Please see below a)html and b)javascript. I activated the js script from default apache directory which is htdocs directory where I placed the javascript if you refer the my html above.

Installed IE6


a) html
=====
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
  2.  
  3. <html> 
  4. <head>
  5. <SCRIPT LANGUAGE="JAVASCRIPT" SRC="j_pop5.js"
  6. TYPE="TEXT/JAVASCRIPT">
  7. <!--
  8.  
  9. //-->
  10. </SCRIPT>
  11. </head> 
  12.  
  13. <body>
  14. </body>
  15. </html>
  16.  
  17.  

javascript
=======

Expand|Select|Wrap|Line Numbers
  1. Expand|Select|Wrap|Line Numbers <script language="JavaScript1.2" type="text/javascript"> 
  2. <!-- ; 
  3. alert("Welcome to my world!!!"); 
  4.  
  5.  
Nov 9 '08 #5
gits
5,390 Recognized Expert Moderator Expert
there is nothing missing ... it is just too much ... leave the script-tags out and drop those useless comment ... just the alert() should be left in the JS-file ... here is an example ...

regards
Nov 9 '08 #6
Markus
6,050 Recognized Expert Expert
--Moved to Javascript.

Another thing to note: everything should be lowercase if you wish to comply with HTML standards. The 'language' attribute is deprecated (not needed or supported).
Nov 9 '08 #7
gits
5,390 Recognized Expert Moderator Expert
hi happyse27,

i just closed the following threads that are handling the same issue:

http://bytes.com/forum/thread851230.html
http://bytes.com/forum/thread852374.html

please try to keep one thread for a specific problem ... since otherwise it would lead to just spreaded information and answers ... i don't feel like merging all the threads since some different lines of code are posted there and some different hints and answers but as far as i could see the problem is always the same and so we should just use this thread here. i linked everything together so we could jump from thread to thread.

kind regards
MOD
Nov 9 '08 #8
happyse27
236 New Member
Hi Sir,

Thanks and noted, sorry and apologize because I did that because I dont know if it belongs to javascript issue or html's therefore did double post. Anyway, I tried your method. But still the alert message below did not pop up... Checked apache access log is it error 500 and error 543. Kindly advise what is happening???


The example you given..
=============== ==
this is the page where a script is included:
Expand|Select|Wrap|Line Numbers
  1. <html> 
  2.     <head> 
  3.         <script type="text/javascript" src="foo.js"/> 
  4.     </head> 
  5.     <body> 
  6.     </body> 
  7. </html> 
  8.  
and this is in the file foo.js:
Expand|Select|Wrap|Line Numbers
  1. alert('foo'); 
  2.  
Error from apache access if I put javapop.js into apache/cgi-bin directory
=============== =============== =============== ==
127.0.0.1 - - [09/Nov/2008:22:00:28 -0800] "GET /javapop.html HTTP/1.1" 304 -
127.0.0.1 - - [09/Nov/2008:22:00:28 -0800] "GET /cgi-bin/javapop.js HTTP/1.1" 500 543

Error from apache access if I put javapop.js into apache/htdocs directory
=============== =============== =============== ==
127.0.0.1 - - [09/Nov/2008:21:56:24 -0800] "GET /javapop.html HTTP/1.1" 304 -
127.0.0.1 - - [09/Nov/2008:21:56:24 -0800] "GET /javapop.js HTTP/1.1" 304 -
Nov 9 '08 #9
gits
5,390 Recognized Expert Moderator Expert
just clear your browser cache first and try the second method again ... does the files just contain the example?
Nov 9 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

26
15216
by: Don | last post by:
I'm writing an html page with some JavaScript that reads a web page into a client-side temp file, then reformats it, then submits that same file as a URL to the browser for display, via "locate.replace". I can do all this if the html page containing the script originates on the client machine, but don't know how to get access to a client-side temp file when the same html page containing the script is on a web host. How do I get access...
7
1675
by: e | last post by:
I've been having an extremely difficult time finding an answer to this in IE / js groups, so I thought I'd try here. I've got an aspx page that delivers loads of report data into custom-named <span> tags on the client, hidden from the screen by @media classes. From a dynamically built menu of what was returned, the user selects wich report they want to view/print and a little jscript .innerHTML magic happens under the hood that copies...
5
10901
by: punchbag | last post by:
Hi all, There has recently been a new update to internet explorer whereby activex controls now load on a page unactivated. MSDN have a website explaining a workaround where you do away with the <OBJECT> tag in your html and instead use an external Javascript the control will load activated. http://msdn.microsoft.com/library/?url=/workshop/author/dhtml/overview/activating_activex.asp
2
4793
by: dominic.martin | last post by:
Hi, I'm no javascript programmer but I found a really good piece of javascript at http://www.isdntek.com/tagbot/zipzoom.htm that magnifies areas of an image. It's just what I want but their example only allows for a button in the HTML body to turn the magnifier on: <input type="button" onclick="initMagnifier()" value="Use Magnifier"> I would like two buttons; one to activate the magnifier and one to
8
2601
by: Frank | last post by:
Hi, I am working with VS.NET 2005 Ultimately, I wish to call a JavaScript function from a .js file
4
5875
by: Ed | last post by:
I'm writing a VBA macro in Word 2003 that finds and manipulates a web page (Win XP, IE6 sp2). I am having trouble with a checkbox. I can find the checkbox and make it checked, but I can't figure out how to activate the function connected to the OnClick event. Would anyone be able to help me out here, please? Thanks. Ed
4
5249
by: happyse27 | last post by:
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...
0
8411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8613
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.