473,564 Members | 2,758 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting information from a hidden IFrame

This might beyond the scope of this group because it deals with
SharePoint, but I'm not sure if I can't get it to work because of
SharePoint or because JavaScript is weird (I don't have much experience
with JavaScript).

Anyway, here is the code i'm working with. Basically, it creates
appends a hidden IFrame to the page, gets the links from the IFrame,
and displays those which have the "OnLink" property. The weird thing
is that when I uncomment out the alert("x=0") line, it works fine. If
I don't have an alert, then nothing will be written to the page (the
page already exists, I'm adding the JavaScript to the page as a Content
Editor Web Part).

var links;
var hiddenIframe = document.create Element("IFRAME ");
var linksArray = new Array();
var x = null;

hiddenIframe.id = "iLinks";
hiddenIframe.st yle.display = "none";
hiddenIframe.sr c = "source of links";
WebPart_WPQ_.ap pendChild(hidde nIframe);

links = frames["iLinks"].document.getEl ementsByTagName ("A");
x = 0;
//alert("x=0");

for (var i=0; i<links.length ; i++)
{
var templink = links(i);
var onValues = templink.onclic k + templink.onfocu s + "";

if(onValues.ind exOf("OnLink") >= 0)
{
linksArray[x] = templink;
x++;
}
}

for (var j=0; j<linksArray.le ngth; j++) {
document.write( linksArray[j] + '<br>');
}

I also tried an alternate solution where I called everything function
on IFrame onLoad, but that deleted everything on the page and wrote the
text instead of writing the text to the specific area where the
function was located (as it does when the alert("x=0") is uncommented
on the above code).

Thanks in advance for any help.

Oct 18 '06 #1
4 2529
Any ideas?

Drew wrote:
This might beyond the scope of this group because it deals with
SharePoint, but I'm not sure if I can't get it to work because of
SharePoint or because JavaScript is weird (I don't have much experience
with JavaScript).

Anyway, here is the code i'm working with. Basically, it creates
appends a hidden IFrame to the page, gets the links from the IFrame,
and displays those which have the "OnLink" property. The weird thing
is that when I uncomment out the alert("x=0") line, it works fine. If
I don't have an alert, then nothing will be written to the page (the
page already exists, I'm adding the JavaScript to the page as a Content
Editor Web Part).

var links;
var hiddenIframe = document.create Element("IFRAME ");
var linksArray = new Array();
var x = null;

hiddenIframe.id = "iLinks";
hiddenIframe.st yle.display = "none";
hiddenIframe.sr c = "source of links";
WebPart_WPQ_.ap pendChild(hidde nIframe);

links = frames["iLinks"].document.getEl ementsByTagName ("A");
x = 0;
//alert("x=0");

for (var i=0; i<links.length ; i++)
{
var templink = links(i);
var onValues = templink.onclic k + templink.onfocu s + "";

if(onValues.ind exOf("OnLink") >= 0)
{
linksArray[x] = templink;
x++;
}
}

for (var j=0; j<linksArray.le ngth; j++) {
document.write( linksArray[j] + '<br>');
}

I also tried an alternate solution where I called everything function
on IFrame onLoad, but that deleted everything on the page and wrote the
text instead of writing the text to the specific area where the
function was located (as it does when the alert("x=0") is uncommented
on the above code).

Thanks in advance for any help.
Oct 20 '06 #2
ASM
Drew a écrit :
>Anyway, here is the code i'm working with. Basically, it creates
appends a hidden IFrame to the page, gets the links from the IFrame,
and displays those which have the "OnLink" property. The weird thing
is that when I uncomment out the alert("x=0") line, it works fine. If
I don't have an alert, then nothing will be written to the page (the
page already exists, I'm adding the JavaScript to the page as a Content
Editor Web Part).
with the complet function or an example in line
it would have been better ...
>>
var links;
var hiddenIframe = document.create Element("IFRAME ");
var linksArray = new Array();
var x = null;

hiddenIframe.i d = "iLinks";
hiddenIframe.s tyle.display = "none";
hiddenIframe.s rc = "source of links";
perhaps you need new iframe finish to load the file "source of links" ?

hiddenIframe.on load = function() {
// don't forget to close this function at end of script
>links = frames["iLinks"].document.getEl ementsByTagName ("A");
x = 0;
//alert("x=0");

for (var i=0; i<links.length ; i++)
{
var templink = links(i);
var onValues = templink.onclic k + templink.onfocu s + "";

if(onValues.ind exOf("OnLink") >= 0)
{
linksArray[x] = templink;
x++;
}
}
for (var j=0; j<linksArray.le ngth; j++) {
document.write( linksArray[j] + '<br>');
}
var txt = '';
for (var j=0; j<linksArray.le ngth; j++) txt += linksArray[j] + '<br>';
document.write( txt); // that would have to write in hidden iframe

} // supposed end of iframe's onload function

WebPart_WPQ_.ap pendChild(hidde nIframe);

}

>I also tried an alternate solution where I called everything function
on IFrame onLoad, but that deleted everything on the page and wrote the
text instead of writing the text to the specific area where the
function was located (as it does when the alert("x=0") is uncommented
on the above code).
the onload is to be set before the appendChild

and ... specific areas ... how to consider them with a bit of code as
given ?

you want that write on main page ?
parent.document .write(txt); // would have to write in main page

to write (or add) to div 'someWhere' on main page :
parent.document .getElementById ('someWhere').i nnerHTML = txt;
--
ASM
Oct 20 '06 #3
that actually was the complete function. the rest of the page is
automatically created by sharepoint, which i have no control over it
(which is why we're trying to use scripts so we can get more out of
sharepoint). the original code given will write directly to the parent
page, which is what i want. here is the alternate script was referring
to:

<script language="JavaS cript">
var links;
var linksArray = new Array();
var contentsArray = new Array();
var x = null;
function getLinks()
{
links = frames["iLinks"].document.getEl ementsByTagName ("A");

x = 0;

for (var i=0; i<links.length ; i++)
{
var templink = links(i);
var onValues = templink.onclic k + templink.onfocu s + "";
if(onValues.ind exOf("OnLink") >= 0)
{
linksArray[x] = templink;
contentsArray[x] = links(i).innerH TML;
x++;
}
}
writeLinks();
}

function writeLinks()
{
for (var j=0; j<linksArray.le ngth; j++)
{
parent.document .write(contents Array[j].link(linksArra y[j]) +
'<br>');
}
}

function mainFunc()
{
var hiddenIframe = document.create Element("IFRAME ");
hiddenIframe.at tachEvent("onlo ad", getLinks);
hiddenIframe.id = "iLinks";
hiddenIframe.st yle.display = "none";
hiddenIframe.sr c =
"http://teamsites.wacho via.net/it/communications/ITIGProjectCent er/testcenter2/Lists/Links/AllItems.aspx";
WebPart_WPQ_.ap pendChild(hidde nIframe);
}

window.attachEv ent("onload", mainFunc);
</script>


this script, however, will clear the entire sharepoint page and write
the first link of the array.

ASM wrote:
Drew a écrit :
Anyway, here is the code i'm working with. Basically, it creates
appends a hidden IFrame to the page, gets the links from the IFrame,
and displays those which have the "OnLink" property. The weird thing
is that when I uncomment out the alert("x=0") line, it works fine. If
I don't have an alert, then nothing will be written to the page (the
page already exists, I'm adding the JavaScript to the page as a Content
Editor Web Part).

with the complet function or an example in line
it would have been better ...
>
var links;
var hiddenIframe = document.create Element("IFRAME ");
var linksArray = new Array();
var x = null;

hiddenIframe.id = "iLinks";
hiddenIframe.st yle.display = "none";
hiddenIframe.sr c = "source of links";

perhaps you need new iframe finish to load the file "source of links" ?

hiddenIframe.on load = function() {
// don't forget to close this function at end of script
links = frames["iLinks"].document.getEl ementsByTagName ("A");
x = 0;
//alert("x=0");

for (var i=0; i<links.length ; i++)
{
var templink = links(i);
var onValues = templink.onclic k + templink.onfocu s + "";

if(onValues.ind exOf("OnLink") >= 0)
{
linksArray[x] = templink;
x++;
}
}
for (var j=0; j<linksArray.le ngth; j++) {
document.write( linksArray[j] + '<br>');
}

var txt = '';
for (var j=0; j<linksArray.le ngth; j++) txt += linksArray[j] + '<br>';
document.write( txt); // that would have to write in hidden iframe

} // supposed end of iframe's onload function

WebPart_WPQ_.ap pendChild(hidde nIframe);

}

I also tried an alternate solution where I called everything function
on IFrame onLoad, but that deleted everything on the page and wrote the
text instead of writing the text to the specific area where the
function was located (as it does when the alert("x=0") is uncommented
on the above code).

the onload is to be set before the appendChild

and ... specific areas ... how to consider them with a bit of code as
given ?

you want that write on main page ?
parent.document .write(txt); // would have to write in main page

to write (or add) to div 'someWhere' on main page :
parent.document .getElementById ('someWhere').i nnerHTML = txt;
--
ASM
Oct 20 '06 #4
I finally figured it out. I think the problem was in the way
SharePoint was set up, it may have worked under different
circumstances. Here is my way around it though, if anyone is
interested:

<script language="JavaS cript">
var links;
var linksArray = new Array();
var contentsArray = new Array();
var x = null;
var tbl = document.create Element("TABLE" );
var tbody = document.create Element("TBODY" );

function getLinks()
{
links = frames["iLinks"].document.getEl ementsByTagName ("A");

x = 0;

for (var i=0; i<links.length ; i++)
{
var templink = links(i);
var onValues = templink.onclic k + templink.onfocu s + "";
if(onValues.ind exOf("OnLink") >= 0)
{
linksArray[x] = templink;
contentsArray[x] = links(i).innerH TML;
x++;
}
}
writeLinks();
}

function writeLinks()
{
for (var j=0; j<linksArray.le ngth; j++)
{
var tr = document.create Element("TR");
var td = document.create Element("TD");
var aLink = document.create Element("A");
aLink.setAttrib ute("href", linksArray[j]);
aLink.appendChi ld(document.cre ateTextNode(con tentsArray[j]));
td.appendChild( aLink);
tr.appendChild( td);
tbody.appendChi ld(tr);
}

tbl.appendChild (tbody);
WebPart_WPQ_.ap pendChild(tbl);
}

function mainFunc()
{
var hiddenIframe = document.create Element("IFRAME ");
hiddenIframe.at tachEvent("onlo ad", getLinks);
hiddenIframe.id = "iLinks";
hiddenIframe.st yle.display = "none";
hiddenIframe.sr c = "URL of links list";
WebPart_WPQ_.ap pendChild(hidde nIframe);
}
window.attachEv ent("onload", mainFunc);
</script>

Oct 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1824
by: Matt | last post by:
I want to open a page that is hidden to the user. Some people suggest me to use hidden iframe. Is it a good solution? Any good examples?
6
3894
by: fniyogi | last post by:
Does anyone know how to suppress the "busy"/hourglass cursor that appears when a frame/iframe is loading, as in the g() functon below: <SCRIPT> function g() { if ( Math.floor(Math.random()*2) == 1 ) frames.location.href = "http://www.yahoo.com"; else frames.location.href = "http://games.yahoo.com"; }
1
4677
by: tllcll | last post by:
Hi, I would like to find out how to handle the following: I retrieve the data from the database by calling javabean and return the data back to the same jsp page and then display those values using html/javascript in the dropdown listbox. how to get the value selected by user (to be used in java - as a condition - for retrieving data...
10
3788
by: jon | last post by:
I'm trying to use a hidden iframe to print the contents of one div seamlessly. Currently I can create the hidden iframe, copy the contents of the div to the iframe, and print it. I even have a method that initially copies all the original page's styles onto the new iframe to maintain look and feel. So far things work, and the div (along...
5
2047
by: pbd22 | last post by:
hi. i have a hidden iframe for uploading files. when i check the httpfilecollection on the server, it is always zero - the files never make it to the server. i know all the javascript is working correctly on the client b/c i have followed the local variables using venkman. so, something is happening on the server.
5
2673
by: pbd22 | last post by:
Hi. I am trying to poll a long-running process via a hidden IFrame. I am noticing that the online errata gives advice for handling a server response: window.parent.handleServerResponse(); The problem I am having with this is that the above function gets called ***after*** the long-running response is completed.
1
4026
by: Turin | last post by:
I'm trying to put a print button on a page that will open the print dialog box for a PDF that there is no need to open. My original plan was to use a hidden iframe calling a javascript function that does what everyone suggests function iPrint(myFrame) { myFrame.focus(); myFrame.print(): } Everything I've tried along these lines...
6
4101
by: buntyindia | last post by:
Hi, I have a page. There is a section 'sidebar' where bulleted text is there. Just after first bullet there is a hidden IFRAME. That go visible on clicking of that bullet text. My problem is with Safari Browser in Mac and WindowsXP. When we press the tab after first bullet link instead of going to next bulleted text the focus goes to the...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.