473,396 Members | 2,052 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,396 software developers and data experts.

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 1802
.... 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ian Richardson | last post by:
If I follow the steps on http://www.dhtmlcentral.com/tutorials/tutorials.asp?id=11 to add .js files to a document on demand, let's say by <body onload="blah();">, how can I reliably tell that it...
10
by: Pasquale | last post by:
hello wverybody... i've got a terrible matter with JS my browsers (either IE and NN) load the external scripts uncorrectly...they load the files from the half part of them and not from the...
6
by: ku_coyote | last post by:
I have an external file, TestVar.js with a single line. NewsA("This is a test.","test.pdf","TEST") Within my HTML I wish to use the array variables from TestVar.js, but can't seem to get them...
2
by: Christopher Benson-Manica | last post by:
I would like to, for debugging purposes, obtain the contents of a <script> element. I'm aware that the text property contains the text contained within the element. However, the <script> element...
5
by: jeet_sen | last post by:
Hi, My external javascript test.js contains a variable definition var a = "Hello,world!!"; I dynamically loaded the script test.js using the following fucntion: function loadScript(url) { var...
1
by: dnn | last post by:
How can I access dynamically loaded variables? I am trying to load an external javascript file dynamically and then access its variables. The script is loaded by the onload handler. The code...
4
by: volker | last post by:
Hi, I'm trying to move an iframe from one position in the DOM to another. The moving itself is not a problem at all, but I experience a different behaviour between Firefox (1.5) and IE (6): As...
2
ak1dnar
by: ak1dnar | last post by:
Hi, there is requirement to read some external documents from my web application. I'll further explain it like this. I am working on a web application that helps to read the contents of the...
9
by: mevryck | last post by:
Greetings I have a huge Javascript with inclusion of external scripts and all. I got this by doing a XSLT . Now I have the contents in a Javascript variable, but I'm not able to update the...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.