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

Home Posts Topics Members FAQ

Any variable in embedded javascript to reference the object embedsthe script?

For example, I have the following code:

<img src="photo_ring _r1_c1.jpg" title="" alt="Rings"
style="width: 200px; height: 150px;" usemap="#photo_ ring_r1_c1">
<map name="photo_rin g_r1_c1">
<area shape="circle" coords="30,30,3 0"
href="javascrip t:show_details( 'ring1');" alt="ring1" title="ring1">
</map>

Is it possible to modify the

href="javascrip t:show_details( 'ring1');"

to something like

href="javascrip t:show_details( embeddedObject. tags.alt);"

So the 'alt' of area shape will be the parameter of teh show_details
function?

Jul 20 '05 #1
4 1683
Nick <nb**********@h otmail.com> writes:
For example, I have the following code:

<img src="photo_ring _r1_c1.jpg" title="" alt="Rings"
style="width: 200px; height: 150px;" usemap="#photo_ ring_r1_c1">
<map name="photo_rin g_r1_c1">
<area shape="circle" coords="30,30,3 0"
href="javascrip t:show_details( 'ring1');" alt="ring1" title="ring1">
</map>

Is it possible to modify the

href="javascrip t:show_details( 'ring1');"

to something like

href="javascrip t:show_details( embeddedObject. tags.alt);"
Yes. First of all, you should not use a "javascript :"-URL. For several
reasons <URL:http://jibbering.com/faq/index.html#FAQ4 _24>.
Instead, use the onclick attribute.

You should also use the title attribute appropriately. It should contain
information that further describes the element. The alt attribute
should be used for information that is shown when the browser can't
show the area graphically (e.g., a text browser). They are not the same,
and should be used differently.
So the 'alt' of area shape will be the parameter of teh show_details
function?


<area shape="circle" coords="30,30,3 0"
href="thisLinkN eedsJS.html" alt="Foobar" title="Informat ion about Foobar"
onclick="show_d etails(this.alt );">

The href should point to a page that explains that your page requires
Javascript to function correctly (and why, if you can defend it).
A signifiacnt number of people browse with Javascript turned off
or not available.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Lasse Reichstein Nielsen wrote:
Nick <nb**********@h otmail.com> writes:

For example, I have the following code:

<img src="photo_ring _r1_c1.jpg" title="" alt="Rings"
style="width: 200px; height: 150px;" usemap="#photo_ ring_r1_c1">
<map name="photo_rin g_r1_c1">
<area shape="circle" coords="30,30,3 0"
href="javascrip t:show_details( 'ring1');" alt="ring1" title="ring1">
</map>

Is it possible to modify the

href="javascr ipt:show_detail s('ring1');"

to something like

href="javascr ipt:show_detail s(embeddedObjec t.tags.alt);"

Yes. First of all, you should not use a "javascript :"-URL. For several
reasons <URL:http://jibbering.com/faq/index.html#FAQ4 _24>.
Instead, use the onclick attribute.

You should also use the title attribute appropriately. It should contain
information that further describes the element. The alt attribute
should be used for information that is shown when the browser can't
show the area graphically (e.g., a text browser). They are not the same,
and should be used differently.

So the 'alt' of area shape will be the parameter of teh show_details
function?

<area shape="circle" coords="30,30,3 0"
href="thisLinkN eedsJS.html" alt="Foobar" title="Informat ion about Foobar"
onclick="show_d etails(this.alt );">

The href should point to a page that explains that your page requires
Javascript to function correctly (and why, if you can defend it).
A signifiacnt number of people browse with Javascript turned off
or not available.

/L


I am using javascript to open a popup window. It can also be done using
onclick. However, I don't want the main page go to any url. And the
dreamweaver use href="#" and it really annoy because the page always
scroll to the beginning of the hmtl after click the map (and it will
always go to the URL of href if putting any URL there).

Currently I am using

href="javascrip t:;" to void the page scrolling to beginning.

And I also found that href="javascrip t:showPopup(thi s.alt)" doesn't
work. but onclick="javasc ript:showPopup( this.alt)" works well.
Interesting.... (I tested it on IE 6).
Jul 20 '05 #3
Nick <nb**********@h otmail.com> writes:
I am using javascript to open a popup window.
Dangerous.
It can also be done using onclick. However, I don't want the main
page go to any url.
In that case, do as the FAQ says, not as I say :)
Because I forgot to add the "return false" at the end of the onclick
handler which would prevent the normal operation of the link.
And the dreamweaver use href="#"
Bad idea. Even href="" is better, but neither are the slightest bit
useful to someone with no Javascript.
and it really annoy because the page always scroll to the beginning
of the hmtl after click the map (and it will always go to the URL of
href if putting any URL there).
unless you return false, i.e.,
onclick="show_d etails(this.alt );return false;"
Currently I am using

href="javascrip t:;" to void the page scrolling to beginning.
Worse, for all the reasons in the FAQ.
And I also found that href="javascrip t:showPopup(thi s.alt)" doesn't
work. but onclick="javasc ript:showPopup( this.alt)" works
well. Interesting.... (I tested it on IE 6).


That is because the javascript in the first is executed in the global
scope (just as if you typed it in the address line), so "this" refers
to the global object. The second is executed as a property of the
element, so "this" refers to the element.

You don't need "javascript :" in front of onclick handlers!
By coincidence, it is not a syntax error, but it doesn't do anything.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
Thanks very much. I've changed according to your suggestions. However,
for the browsers without javascript(or dissabled). Currently it seems
javascript is so widely used and some tools like VisualStudio.Ne t's
ASP.Net development environment even automatically generate javascript
when dragging the component to the web page. I guess some JSP
development tools do the same too.

So hopefully, Javascript is automatically supported by most end-users'
browser.
Jul 20 '05 #5

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

Similar topics

1
3933
by: Gnarlodious | last post by:
I want to send a variable to a styleswitching script that will be a function of where the script is in the folder structure. The script will then assemble the stylesheet URL around the variable. For example, the variable "../../../../" would need to be sent to the script, how will I do this? Here is the script: http://www.Spectrumology.com/Styles/switcher.js
4
4770
by: comcast news | last post by:
at least i think it this is the problem am trying to fix a webpage/javascript that i didn't write www.deltaneutral.com when invoked or any new page from the menu, get the error msg line 2 char 1 syntax error code 0 there is a java scipt file invoked early on that 'seems' to be the problem, its just after the body tag
6
9395
by: paul | last post by:
HI! How do we send a variable from an Iframe page back to its parent? I have a script that calculates the iframe's window size but I need to know how to send that value back to its parent so I can use it there. Thanks in advance :) Paul
5
3269
by: Daz | last post by:
Hi everyone. Another simple question which should hopefully warrent a simple answer. I would like a function to be run whenever a variable is updated. I have tried binding the onchange event to it, and it doesn't work. I think I understand why, however, I would like to know if there is anything that I can bind to my variable that will fire the specified function whenever the value changes.
2
8171
by: Owen.Leibman | last post by:
Here is a complete web page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html> <head> <title>Javascript Embed and onunload</title> <script type="text/javascript"> function useplayer() { var a = document.getElementById("obj1"); var obj = document.createElement("object"); obj.data = "dayenu.mid";
6
5072
by: Dan | last post by:
Excuse me if i'm being a bit thick here, but is it possible to reference a server side variable within an embedded js source file. For example, my test.js file contains alert('<%=tmpVar%>'); and my aspx page contains:- <script type="text/javascript" src="test.js">
1
25702
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that variable can only be used in that function. If you were to try to access that variable anywhere else in...
3
7412
daJunkCollector
by: daJunkCollector | last post by:
I have the html/javascript posted below, I imagine the fix to my problem is something simple that I am overlooking. My script is a little bit of html and javascript, and there is an embedded flash file written in actionscript. This is a test page, and I am furious that it is posing such a problem. I am communicating between the html and flash object. My goal is to populate the flash object textbox with the value of the html combobox (I...
2
10923
by: neeebs | last post by:
Hi, I'm not sure if this is a javascript problem per se, but here goes. I have an xsl document with a python function defined within a <script> block. Elsewhere in the xsl file, within a python script block, I call the python function and store the return value in a variable. I need to be able to display this returned value on the webpage that the xsl generates. I tried to do a document.write() but found that document.write() causes...
0
9525
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10452
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
10221
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...
1
10169
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
9050
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...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
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...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.