Read the Contents Loaded by an External Script

P

primary0

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).
 
P

primary0

.... 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.
 
A

ASM

primary0 said:
... 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.src+'\n';
foo=window.open();
with(foo.document) {open();write('<pre>'+P+'<\/pre>');close();}
}
and, in the popup, try to find your image
 
P

primary0

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?
 
A

ASM

primary0 said:
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 && fram.document.images)
P += 'frame '+i+' : (name = '+frams.name+')\n';
var I=fram.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top