473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

problem hiding all image files in a html file

Here is my source code which completely works:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.   <body>
  3.     <div id="div1">div1</div>
  4.     <div id="div2">div2</div>
  5.     <a href=# onclick=check()>delete all div</a>
  6.  
  7.     <script>
  8.      function check(){
  9.         x = document.getElementsByTagName("div");
  10.  
  11.         while(x.length>0){
  12.           document.getElementsByTagName("body")[0].removeChild(x[0]);
  13.     }
  14.      }
  15.     </script>
  16.   </body>
  17. </html>

However, this code will not work:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.   <body>
  3.     <img id="img1" src='image1.jpg'>
  4.     <img id="img2" src='image2.jpg'>
  5.     <a href=# onclick=check()>delete all img</a>
  6.  
  7.     <script>
  8.      function check(){
  9.         x = document.getElementsByTagName("img");
  10.  
  11.         while(x.length>0){
  12.           document.getElementsByTagName("body")[0].removeChild(x[0]);
  13.     }
  14.      }
  15.     </script>
  16.   </body>
  17. </html>
I want to hide all images of my webpage.
Any help appreciated.
Jan 5 '10 #1

✓ answered by Dormilich

I do apologize for any inconvenience I might have caused.
what inconvenience?
however, this code will not remove advertisement images.
maybe they are flash objects?
P.S. When you copy and paste, […] please remove that space when you paste it in location bar
if you wrap that in [code] … [/code], that doesn’t happen.

3 1466
Dormilich
8,658 Expert Mod 8TB
However, this code will not work:
well, it works for me (FF 3.5/Mac)
Jan 5 '10 #2
Dormilich,
I do apologize for any inconvenience I might have caused.

Actually, this is what I am trying to do:
Here is my code,

Expand|Select|Wrap|Line Numbers
  1. javascript:void(x=document.getElementsByTagName("img"));for(i=0;i<x.length;i++){void(x[i].style.display="none")}
you can type this in the browser's location bar,

What I wanted to do is to hide all the unnecessary images (the advertisements image) on the page,

The code works perfect on google images pages and some images pages, however, this code will not remove advertisement images.

Any help is appreciated.

P.S. When you copy and paste, you will get an unnecessary space character in the line getElementById("img"), please remove that space when you paste it in location bar
Jan 5 '10 #3
Dormilich
8,658 Expert Mod 8TB
I do apologize for any inconvenience I might have caused.
what inconvenience?
however, this code will not remove advertisement images.
maybe they are flash objects?
P.S. When you copy and paste, […] please remove that space when you paste it in location bar
if you wrap that in [code] … [/code], that doesn’t happen.
Jan 5 '10 #4

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

Similar topics

6
by: Zaan | last post by:
www.entropy.ch release for Mac OS X.] Hello, My issue is the following: to promote consistency on a site I'm building, I decided to go for a php scheme where some recurring elements...
4
by: web_design | last post by:
I put this together from some other scripts I am using on a site. I'm trying to make a better email hiding script. It isn't working. Also, it causes Internet Explorer 6 SP2 to block the script...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
1
by: goldtech | last post by:
Is there a way to create thumnails with a script in PHP with safe mode ON? We want to keep safe mode ON for our server but beable to automatically create thumbs from full size image files. Is...
1
by: antony | last post by:
It run w/o error but no image appears. Please help me. Here si the code I do " <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page...
2
by: prakharv | last post by:
Hi All, Below is the code which I am using to upload a jpeg file to the server. But the problem I am facing is that it is not copying the entire contents of the image file to the webserver and it...
0
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I have not tried this before. I have been building an ASP.Net 2.0 app for some weeks now and up till now I have not had any problems publishing. I was given a Word doc to include in the app. I...
4
cassbiz
by: cassbiz | last post by:
Could use some help here. This script is carrying over an image just fine but the text isn't coming over. can you see why it is not working???? from the form I want to carry over two lines of...
5
by: creative1 | last post by:
hi everyone, I am struck in layout of my site. Im using 1024 fixed width layout. I have a site layout designed in psd files. Bisically I have to stick with that design tightly and I am asked not to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.