473,796 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to actiavate javascript in html - need to install anything?

236 New Member
Hi all,

I have enabled Javascripting in internet explorer 7, and I have been writing script in perl.

The thing I cant do now is to pop up image in small html frame from main html page.... The result of the main html showed blank. Any idea?


Thanks and Best Rgds,
Andrew


a) html script - not sure if the directory perl is correct, put into cgi-bin directory in perl but cant work, so put into d drive...
=============== ===============

Expand|Select|Wrap|Line Numbers
  1.  
  2. <html> 
  3.    <head> 
  4.      <script src="d:testjava-mod.js"> 
  5.      </script>   
  6.  
  7.    </head> 
  8.  
  9.    <body>
  10.    </body>
  11. </html>
  12.  
  13.  

javascript(chan ged to d drive from perl default script directory still cannot activate script)
========
Expand|Select|Wrap|Line Numbers
  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Java Popup Window Example with size, title and background colour parameters</TITLE>
  5. <script language="JavaScript1.2" type="text/javascript">
  6. <!-- ;
  7. var newwindow;
  8. var wheight = 0, wwidth = 0;
  9.  
  10. function popitup5(url, title, iwidth, iheight, colour) {
  11. var pwidth, pheight;
  12.  
  13. if ( !newwindow || newwindow.closed ) {
  14. pwidth=iwidth+30;
  15. pheight=iheight+30;
  16. newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10');
  17. wheight=iheight;
  18. wwidth=iwidth;
  19. }
  20.  
  21. if (wheight!=iheight || wwidth!=iwidth ) {
  22. pwidth=iwidth+30;
  23. pheight=iheight+90;
  24. newwindow.resizeTo(pwidth, pheight);
  25. wheight=iheight;
  26. wwidth=iwidth;
  27. }
  28.  
  29. newwindow.document.clear();
  30. newwindow.focus();
  31. newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
  32. newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >');
  33. newwindow.document.writeln('<\/center> <\/body> <\/html>');
  34. newwindow.document.close();
  35. newwindow.focus();
  36. }
  37.  
  38. // Routines to tidy up popup windows when page is left
  39. // Call with an onUnload="tidy5()" in body tag
  40.  
  41. function tidy5() {
  42. if (newwindow && !newwindow.closed) { newwindow.close(); }
  43. }
  44.  
  45. // Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->
  46. </script>
  47.  
  48.  
  49. </HEAD> 
  50.  
  51. <BODY onUnload="tidy5()" > 
  52.  
  53. <A HREF="javascript:popitup5('d:0002.jpg','Temple of Heavenly Bliss', 384, 288,'white')"><IMG SRC="d: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> 
  54.  
  55. </BODY>
  56. </HTML>
Nov 4 '08 #1
10 1631
pronerd
392 Recognized Expert Contributor
The source attribute needs to be a URL or URI. You can not use the local file system path.
Nov 4 '08 #2
happyse27
236 New Member
Hi Sir,

Thanks! I have used the URL, still cant work.

Kindly advise, or rather, any sample to refer to ?? Thanks in advance.


Cheers...
Andrew
Nov 5 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
Is b) the JavaScript file? It should contain only JavaScript code, not HTML.
Nov 6 '08 #4
happyse27
236 New Member
Hi Sir,

I have managed to activate from internet explorer d:testjava-mod.html. Realised that just need to insert javascript into html(see below item a). And the html page showed a rectange, but the actual picture not shown. I have put the picture 0002.jpg into d drive as well. Not sure why the picture not shown?

But how do I call from a javascript .js file from html item b) syntax below? Got difficulty doing that.
The format of the javascript file that is called from the html page is how?


Thanks and Best Rgds,
Andrew


a) javascript in html
===============
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <html> 
  4.    <head> 
  5. <TITLE>Java Popup Window Example with size, title and background colour parameters</TITLE>
  6. <script language="JavaScript1.2" type="text/javascript">
  7. <!-- ;
  8. var newwindow;
  9. var wheight = 0, wwidth = 0;
  10.  
  11. function popitup5(url, title, iwidth, iheight, colour) {
  12. var pwidth, pheight;
  13.  
  14. if ( !newwindow || newwindow.closed ) {
  15. pwidth=iwidth+30;
  16. pheight=iheight+30;
  17. newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10');
  18. wheight=iheight;
  19. wwidth=iwidth;
  20. }
  21.  
  22. if (wheight!=iheight || wwidth!=iwidth ) {
  23. pwidth=iwidth+30;
  24. pheight=iheight+90;
  25. newwindow.resizeTo(pwidth, pheight);
  26. wheight=iheight;
  27. wwidth=iwidth;
  28. }
  29.  
  30. newwindow.document.clear();
  31. newwindow.focus();
  32. newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
  33. newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >');
  34. newwindow.document.writeln('<\/center> <\/body> <\/html>');
  35. newwindow.document.close();
  36. newwindow.focus();
  37. }
  38.  
  39. // Routines to tidy up popup windows when page is left
  40. // Call with an onUnload="tidy5()" in body tag
  41.  
  42. function tidy5() {
  43. if (newwindow && !newwindow.closed) { newwindow.close(); }
  44. }
  45.  
  46. // Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->
  47. </script>
  48.  
  49.   </head> 
  50.  
  51. <BODY onUnload="tidy5()" > 
  52.  
  53. <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> 
  54.  
  55.  
  56.  
  57.    </body>
  58. </html>
  59.  
  60.  

b) html to activate javascript
=============== ======

Expand|Select|Wrap|Line Numbers
  1. <html> 
  2.    <head> 
  3.      <script src="/cgi-bin/testjava-mod.js"> 
  4.      </script>   
  5.    </head> 
  6.  
  7.    <body>
  8.    </body>
  9. </html>
  10.  
  11.  
Nov 6 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
In b), what are the contents of testjava-mod.js? Is the relative path correct, i.e. is the JavaScript file in the cgi-bin folder relative to the location of the HTML file?
Nov 6 '08 #6
happyse27
236 New Member
Hi,

How to do that? I just want to know the sample layout of .js when I call from my above html code? Kindly assist. Thanks.


Best Rgds,
Andrew
Nov 8 '08 #7
gits
5,390 Recognized Expert Moderator Expert
as you see :: acoder asked you a question ... and typically a question requires an answer and not a question in return :) ... basicly he asked you to check whether the location of your included JS-code is correct? is it? in case it is not then fix that first please ... otherwise just confirm that the location is ok ... for a quick test just write an alert to line1 of your javascript-file and have a look whether it is called or not when the page is loaded.

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

Yes, the path is correct, but 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.


a) html
=====
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<SCRIPT LANGUAGE="JAVAS CRIPT" SRC="j_pop5.js"
TYPE="TEXT/JAVASCRIPT">
<!--

//-->
</SCRIPT>
</head>

<body>
</body>
</html>


javascript
=======

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript1.2" type="text/javascript">
  2. <!-- ;
  3. alert("Welcome to my world!!!");
  4.  
  5. // Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->
  6. </script>
  7.  
  8.  
Nov 9 '08 #9
gits
5,390 Recognized Expert Moderator Expert
the only thing that has to be in the js-file is JavaScript-code ... just leave out those script-tags and the useless html-comments ...

regards
Nov 9 '08 #10

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

Similar topics

6
1349
by: TJ | last post by:
Hello All, I posted a question a few days ago entitled "Select element with no selected options". Over the course of the discussion, RobG wrote: > This is just an example, it is not really suitable for the web since > without JavaScript it doesn't work at all and whilst I've stuck to > standards, it will be intolerant of some (particularly older) browsers > - but it is a bit of fun trying to do some of this stuff and create > ...
136
9460
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
0
9673
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
10449
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...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
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
9047
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
7546
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
5440
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...
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
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.