473,569 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unusual behaviour

Hi

The following functions are working propery for IE, Ns 4.x and NS 6+ but
the image I want to display disappears in IE. Why?

function swapPic(layer,i mgName,imgObj) {
o = (n &&
layer?document. layers[layer].document.image s[imgName]:document.image s[imgName]);
if(!o.hasswappe d) o.src = eval(imgObj+".s rc");
}

var oRef = null;
var oRefImg = null;
function keepPic(layer,i mgName,imgObj) {
if(oRef) {
// swap image back
oRef.src = oRefImg;
}
if (document.image s) {
o = (n &&
layer?document. layers[layer].document.image s[imgName]:document.image s[imgName]);
if(o) {
oRef = o
oRefImg = o.src;
o.src = eval(imgObj+".s rc");
o.hasswapped = true;
}
}
}

I use the following link to chose the image I want to display

<area shape="poly" alt="" coords="25,25,2 1,0,30,0"
href="javascrip t:void(0)" title=""
onMouseOver="sw apPic('metera', 'diala','img1') ;"
onClick="keepPi c('metera','dia la','img1');">

<div id="metera"><im g src="images/pointer.aa.gif" alt="" name="diala"
id="diala" width="50" height="50" border="0" usemap="#dialit a"></div>

The image map is a dial with 20 positions on it to display a position on
a dial

--
Cheers!
Ken Tuck
EyeCreate Inc.
Web Site Design | Online Applications | E-Commerce
ph: 705 755-1120
fx: 705 743-9259
http://www.eyecreate.net/

Jul 20 '05 #1
2 1869
Ken Tuck <we*******@eyec reate.net> writes:
The following functions are working propery for IE, Ns 4.x and NS 6+
but the image I want to display disappears in IE. Why?
That is hard to say. When asking for help, you should always supply
these three pices of infomration:

1) What are you doing? (posting or giving a link to *all* of the code
that fails, preferably by cutting down to a *minimal* example that
still exhibits the flaw. If posting code, don't let lines be more than
72 characters wide).

2) What is it supposed to do? All you say is that it is "working
properly", which means we have to guess what the code is supposed to
do (and code is *not* self explanatory, especially when it is known to
be bugged).

3) What does it do? What do you mean by "disappears "? Is it blank, is
it not in the page flow at all, or what? Be exact.
function swapPic(layer,i mgName,imgObj) {
Since you didn't tell, I'll try guessing what these arguments are.

// layer - the name of a NS 4 layer if the image is inside one.
// In general, there could be more than one layer, but in practice
// it amost never happens.
// imgName - the id of the image element to change.
// imgObj - a string containing the name of a global variable.
// A very inefficient way to do it. I'll change it to contain
// the value of the variable instead.
o = (n &&
layer?document. layers[layer].document.image s[imgName]:document.image s[imgName]);
Long line. Luckily neither your nor my newsreader automatically break
lines.

I *assume* that "n" is a global variable that is true if the browser
is Netscape 4. It is not needed. I would make "o" a local variable instead
of global.

var o = (layer && document.layers && document.layers[layer])?
document.layers[layer].document.image s[imgName]:
document.images[imgName];
if(!o.hasswappe d) o.src = eval(imgObj+".s rc");
If you are using eval, you are probably doing something wrong.

if (!o.hasswapped) {o.src = imgObj.src;}
} var oRef = null;

var oRefImg = null;
This is later used as the src property of an image, so a better name would
be "oRefSrc".
function keepPic(layer,i mgName,imgObj) {
if(oRef) {
// swap image back
oRef.src = oRefImg;
} if (document.image s) {
Why check for document.images here, and not in the previous function.
o = (n &&
layer?document. layers[layer].document.image s[imgName]:document.image s[imgName]);
As above.
if(o) {
oRef = o
oRefImg = o.src;
o.src = eval(imgObj+".s rc");
o.src = imgObj.src;
o.hasswapped = true;
}
}
} I use the following link to chose the image I want to display <area shape="poly" alt="" coords="25,25,2 1,0,30,0"
href="javascrip t:void(0)" title=""
onMouseOver="sw apPic('metera', 'diala','img1') ;"
onmouseover="sw apPic('metera', 'diala',img1)"

No need to send a string containing 'img1' as an argument, if you
just use it to look up the value of the variable of that name. Just
send the value directly.
onClick="keepPi c('metera','dia la','img1');">
onclick="keepPi c('metera','dia la',img1);">
<div id="metera"><im g src="images/pointer.aa.gif" alt="" name="diala"
id="diala" width="50" height="50" border="0" usemap="#dialit a"></div>


/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" <lr*@hotpop.com > wrote in message
news:sm******** **@hotpop.com.. .
Ken Tuck <we*******@eyec reate.net> writes:

<snip>
var oRefImg = null;


This is later used as the src property of an image, so a better
name would be "oRefSrc".


Or maybe sRefSrc if the value it is to hold is a string.

<snip>
<area shape="poly" alt="" coords="25,25,2 1,0,30,0"
href="javascr ipt:void(0)" title=""
onMouseOver=" swapPic('metera ','diala','img1 ');"


onmouseover="sw apPic('metera', 'diala',img1)"

No need to send a string containing 'img1' as an argument, if you
just use it to look up the value of the variable of that
name. Just send the value directly.
onClick="keepPi c('metera','dia la','img1');">


onclick="keepPi c('metera','dia la',img1);">

<snip>

One of the (many) undesirable side effects of executing a javascript
pseudo-protocol URL is that some browsers stop bothering to load image
graphics after its use. Some, but not all, versions of IE exhibit that
effect.

The effect can probably be avoided by returning false from the onclick
handler to cancel the navigation in the HREF, but that makes the
javascript URL pointless as it will only be used (and predictably fail)
in the event that JavaScript is unavailable on the browser.

Richard.
Jul 20 '05 #3

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

Similar topics

11
2263
by: Karlo Basic | last post by:
Greetings! I'm wondering how do the expressions in the following piece of code evaluate and why: #include <iostream> using namespace std; int main() { int n = 5, p;
2
2614
by: Lenster | last post by:
When using PostMessage to post myself a message, the msg and wparam parameters somehow get swapped over. They are in the correct order when calling PostMessage but by the time wndproc handles the message msg is now in the wparam position and msg is set to 0 (NULL message). Does anyone know why this behaviour is occurring ? I've included a...
14
1551
by: Rowland Shaw | last post by:
I've got a databound combo (databound to a System.Data.DataTable), but some rather unpredicatable behaviour -- even though I have 8 rows in the source table, only the first 6 are showing up in the items collection. I've been scratching my head over this for a while now, but can't fathom what could be to blame for this oddity. Has anyone...
5
1863
by: Tino Lange | last post by:
Hi! I'm trying to use the csv Parser included with Python. Field Delimiter is "|", Line Delimiter is "#". Unfortunately it doesn't work as expected. The parser seems to just ignore the 'lineterminator'? Here's some example: > $ cat test.py > #! /usr/bin/env python
15
2069
by: John Howie | last post by:
I've found very unusual behavious when using sessions on two different servers. I'm using sessions to handle simple log in. When the form submits the values are checked against a MySQL table. If a match exists two session variables are created: $_SESSION and $_SESSION. Each page checks if the session variable 'db_is_logged_in' is set and...
7
5365
by: Rithish | last post by:
Hello. I noticed a strange thing while using strtotime() and date() functions in combination to generate from MySQL into a readable format. By default, the MySQL date field will be 0000-00-00 00:00:00 When I pass this to strtotime() to generate the timestamp, and then pass it to the date function, it generates 30-11-1999. <? print (...
7
2641
by: William S Fulton | last post by:
I'm looking for the name of the following casting style in order to do some reading around on it and why it is sometimes used. unsigned long long ull = 0; void * ptr = 0; ull = *(unsigned long long*)&ptr; As opposed to the more usual casting:
0
1103
by: mk | last post by:
http://linux.byexamples.com/archives/365/python-convey-the-exception-traceba That's seriously weird. What's your Python version and platform? On my Windows and Linux machines, with more recent Python versions the above trick works flawlessly. Check your environment, namely PYTHON* variables. There may be something causing this behaviour....
0
213
by: Robert Rawlins | last post by:
That's seriously weird. What's your Python version and platform? On my Thanks for that MK. I'm using Debian with Python 2.5 from the stable apt repository, installed but a couple of days ago. I'll be sure to look into those other elements you suggested also. I'm not sure if it bares any resemblance but this application runs a gobject...
0
7703
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...
0
7618
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...
0
7926
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. ...
0
8138
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...
0
6287
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...
1
5514
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...
0
3657
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...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
946
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...

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.