Is there anyway of disabling images in javascript, so that the alternative
text appears instead of the images?
I'm trying to do a text-only version of my site. 8 9663
Hi,
Yourself wrote: Is there anyway of disabling images in javascript, so that the alternative text appears instead of the images? I'm trying to do a text-only version of my site.
Do you have to do that on the client? That sounds like a server-side job...
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
"Laurent Bugnion" <lb******@bluewin.ch> wrote in message
news:44**********@news.bluewin.ch... Hi,
Yourself wrote: Is there anyway of disabling images in javascript, so that the alternative text appears instead of the images? I'm trying to do a text-only version of my site. Do you have to do that on the client? That sounds like a server-side job...
Yeah it would be nice to do it on the server, but the markup is coming from
a CMS which I can't modify.
HTH, Laurent -- Laurent Bugnion, GalaSoft Software engineering: http://www.galasoft-LB.ch Private/Malaysia: http://mypage.bluewin.ch/lbugnion Support children in Calcutta: http://www.calcutta-espoir.ch
Hi,
Yourself wrote: "Laurent Bugnion" <lb******@bluewin.ch> wrote in message news:44**********@news.bluewin.ch...
Hi,
Yourself wrote:
Is there anyway of disabling images in javascript, so that the alternative text appears instead of the images? I'm trying to do a text-only version of my site.
Do you have to do that on the client? That sounds like a server-side job...
Yeah it would be nice to do it on the server, but the markup is coming from a CMS which I can't modify.
I see.
Well, if you want to hide the pictures from the client, you can
- remove them from the document using DOM Level 2 methods (removeChild)
- hide them using CSS (style.display = "none")
But these two ways are not supported by every client. Especially mobile
clients (PDA) often don't allow this kind of JavaScript manipulations...
What is your target client? And also, what is the purpose of doing that?
If it's just to avoid loading the pictures, then it's not good (because
the pictures will be loaded even if they are hidden).
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Yourself said the following on 6/14/2006 7:13 AM: "Laurent Bugnion" <lb******@bluewin.ch> wrote in message news:44**********@news.bluewin.ch... Hi,
Yourself wrote: Is there anyway of disabling images in javascript, so that the alternative text appears instead of the images? I'm trying to do a text-only version of my site. Do you have to do that on the client? That sounds like a server-side job...
Yeah it would be nice to do it on the server, but the markup is coming from a CMS which I can't modify.
onload of the page, you loop through all images in the document.images
collection and set them to a false image that doesn't exist. Then, the
alt text gets displayed. It doesn't act exactly like disabled images (it
still shows the red X in IE) but it comes close.
Testing offline, FF doesn't change the image but online it does.
window.onload = breakImages;
function breakImages()
{
var totalImages = document.images.length;
for (var i=0;i<totalImages;i++)
{
document.images[i].src = 'fakeImage.jpg';
}
}
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
"Randy Webb" <Hi************@aol.com> wrote in message
news:nO******************************@comcast.com. .. Yourself said the following on 6/14/2006 7:13 AM: "Laurent Bugnion" <lb******@bluewin.ch> wrote in message news:44**********@news.bluewin.ch... Hi,
Yourself wrote: Is there anyway of disabling images in javascript, so that the alternative text appears instead of the images? I'm trying to do a text-only version of my site. Do you have to do that on the client? That sounds like a server-side job...
Yeah it would be nice to do it on the server, but the markup is coming from a CMS which I can't modify.
onload of the page, you loop through all images in the document.images collection and set them to a false image that doesn't exist. Then, the alt text gets displayed. It doesn't act exactly like disabled images (it still shows the red X in IE) but it comes close.
Testing offline, FF doesn't change the image but online it does.
window.onload = breakImages; function breakImages() { var totalImages = document.images.length; for (var i=0;i<totalImages;i++) { document.images[i].src = 'fakeImage.jpg'; } }
Thanks, that's something to go on!
-- Randy comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote on 15 jun 2006 in comp.lang.javascript : Testing offline, FF doesn't change the image but online it does.
window.onload = breakImages; function breakImages() { var totalImages = document.images.length; for (var i=0;i<totalImages;i++) { document.images[i].src = 'fakeImage.jpg'; } }
Using a container <span></span>:
====================================
<script type='text/javascript'>
window.onload = breakImages;
function breakImages() {
var im, myParent;
var i=document.images.length
while (--i+1) {
im = document.images[i]
myParent = im.parentNode
myParent.innerHTML = im.alt
myParent.style.border='black 1px dotted'
}
}
</script>
<span>
<img src='alt1.gif' alt='My alt text 1'>
</span>
-
<span>
<img src='alt2.gif' alt='My alt text 2'>
</span>
-
<span>
<img src='alt3.gif' alt='My alt text 3'>
</span>
============================
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.242... Randy Webb wrote on 15 jun 2006 in comp.lang.javascript: Testing offline, FF doesn't change the image but online it does.
window.onload = breakImages; function breakImages() { var totalImages = document.images.length; for (var i=0;i<totalImages;i++) { document.images[i].src = 'fakeImage.jpg'; } } Using a container <span></span>:
====================================
<script type='text/javascript'> window.onload = breakImages;
function breakImages() { var im, myParent; var i=document.images.length while (--i+1) { im = document.images[i] myParent = im.parentNode myParent.innerHTML = im.alt myParent.style.border='black 1px dotted' } } </script>
<span> <img src='alt1.gif' alt='My alt text 1'> </span> - <span> <img src='alt2.gif' alt='My alt text 2'> </span> - <span> <img src='alt3.gif' alt='My alt text 3'> </span>
============================
That works well, but having to add a span around each image element is a
drag. It's a pity there is no way of replacing an element or changing an
elements type.
-- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
Yourself wrote on 15 jun 2006 in comp.lang.javascript : "Evertjan." <ex**************@interxnl.net> wrote in message news:Xn********************@194.109.133.242... Using a container <span></span>:
====================================
function breakImages() { var im, myParent; var i=document.images.length while (--i+1) { im = document.images[i] myParent = im.parentNode myParent.innerHTML = im.alt myParent.style.border='black 1px dotted'
That works well, but having to add a span around each image element is a drag. It's a pity there is no way of replacing an element or changing an elements type.
There is, at least in IE6:
==========================
<script type='text/javascript'>
window.onload = breakImages;
function breakImages() {
var im, newNode;
var i=document.images.length
while (--i+1) {
im = document.images[i]
newNode = document.createElement("SPAN");
im.replaceNode(newNode);
newNode.innerHTML = im.alt
newNode.style.border='black 1px dotted'
}
}
</script>
<img src='alt1.gif' alt='My alt text 1'>
<br><br>
<img src='alt2.gif' alt='My alt text 2'>
<br><br>
<img src='alt3.gif' alt='My alt text 3'>
====================
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lijun Yang |
last post by:
Hey, I am able to disable the right mouse button on images for netscape
and IE but it won't work for Opera.
Here is the code:
// start of the code
var clickmessage="Sorry, you don't have...
|
by: Els |
last post by:
Hi,
I would like an opinion on the following:
I have a page which is made up of background-images with transparent
linked images in front of it, which on hover show text in CSS popups.
Due to...
|
by: Ken Yu |
last post by:
Hi,
How can i disable "RightClick Menu" in Internet Explorer, when
access the frontpage ?
tks a lot !
Ken
|
by: Mike |
last post by:
I have a form that contains 240 "products". Each Product has a TR. Each TR
contains a Yes and No radio button and a Product-Qty text input.
A situation exists where I have to go through all the...
|
by: wkerplunk |
last post by:
On mouseover it goes to the correct map say TheMap1.jpg and then on mouseOut it defaults back to map, I need to do a onClick that sets the TheMap1.jpg mouseOver to the default TheMap.jpg so the...
|
by: zalph |
last post by:
1- Is it possible to disable the keyboard print screen...
2- ... in javascript? If so, how?
|
by: pythoNewbie |
last post by:
Hi guys
I have 2 javascript functions, First I include which does swap images whenever I pass the mouse over a certain image
<script language="JavaScript" type="text/JavaScript"...
|
by: Geoff Cox |
last post by:
Hello
I have for example
<IMG alt="image" id="IMG1" src="../images/play1.gif"
onClick="getSound(this);">
Can I disable this (stop onlick from working) until another action has
been...
|
by: dkyadav80 |
last post by:
<html>
///
here what shoud be java script for:
->when script run then not display all input text field only display selection field.
->when user select other value for institute only this...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |