468,720 Members | 1,607 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,720 developers. It's quick & easy.

Read the Contents Loaded by an External Script

Hi,

I have a page containing an external javascript which loads an image
onto the webpage. How would it be possible to use javascript to read
the filname (and the dimensions) of the loaded image (something I can
get by right-clicking the image with the mouse, but it is not given in
the source of the page).

Jul 23 '05 #1
4 1662
.... more, the source of the page just shows the path to the external
script and not the source of the image loaded by that script. Another
external script is supposed to read that image file name (perhaps with
a timer, so that it can wait until the image is fully loaded). I hope
this makes clear the issue in hand.

Jul 23 '05 #2
ASM
primary0 wrote:
... more, the source of the page just shows the path to the external
script and not the source of the image loaded by that script. Another
external script is supposed to read that image file name (perhaps with
a timer, so that it can wait until the image is fully loaded). I hope
this makes clear the issue in hand.

there is no mystery in JavaScript
certainly the path of image is somewhere

see in the page where the image is
if by chance this img has a name or/and an id
you'll can catch it's refs

Let's suppose it's id and/or name are 'foo'

function pathImg() {
var P = (document.images && document.images['foo'])?
document.images['foo'].src :
(document.getElementById && document.getElementById('foo'))?
document.getElementById('foo').src :
'';
if(P=='') alert('not found')
else alert('Path =\n'+P);
}

can try too :

function getAllPathImg(){
var P='';
var I=document.images;
for(var i=0;i<I.length;i++) P += I[i].src+'\n';
foo=window.open();
with(foo.document) {open();write('<pre>'+P+'<\/pre>');close();}
}
and, in the popup, try to find your image

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #3
unfortunately, this did not help much. I would like to describe the
situation again.

The image, is an anchor link within this iframe (the iframe content is
generated by a javascript hosted remote). I need to get the name of the
iframe (if there is any), it is right now accessible via
window.frames[0] but I am not able to retrieve the anchor names and
URLS in the contents, or the source of the HTML within the iframe. I
first wait for the iframe to load properly (with a timer) before
attempting to read the iframe contents. Anybody got any ideas?

Jul 23 '05 #4
ASM
primary0 wrote:
unfortunately, this did not help much. I would like to describe the
situation again.
who are are you answering ?

what 'this' no help (copy-paste here at least a few bit of 'this')
The image, is an anchor link within this iframe (the iframe content is
generated by a javascript hosted remote).
Read this JS to find image's url ...
I need to get the name of the
iframe (if there is any), it is right now accessible via
window.frames[0] but I am not able to retrieve the anchor names and
URLS in the contents, or the source of the HTML within the iframe. I
first wait for the iframe to load properly (with a timer)
If you know there is a timer, you know on what it applies, no?
before
attempting to read the iframe contents. Anybody got any ideas?


if your browser accepts dom instructions

function getAllPathImg(){
var P='';
frams = document.getElementsByTagName('FRAMES');
for(var i=0;i<frams.length;i++) {
P += '------------------\n';
if(frams[i] && fram[i].document.images)
P += 'frame '+i+' : (name = '+frams[i].name+')\n';
var I=fram[i].document.images;
for(var j=0;j<I.length;j++) P += ' - '+I[j].src+'\n';
}
foo=window.open();
with(foo.document) {open();write('<pre>'+P+'<\/pre>');close();}
}

and, in the popup, try to find your image

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Ian Richardson | last post: by
10 posts views Thread by Pasquale | last post: by
6 posts views Thread by ku_coyote | last post: by
2 posts views Thread by Christopher Benson-Manica | last post: by
1 post views Thread by dnn | last post: by
ak1dnar
2 posts views Thread by ak1dnar | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Oskars | last post: by
9 posts views Thread by bryonone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.