D
Drew
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.createElement("IFRAME");
var linksArray = new Array();
var x = null;
hiddenIframe.id = "iLinks";
hiddenIframe.style.display = "none";
hiddenIframe.src = "source of links";
WebPart_WPQ_.appendChild(hiddenIframe);
links = frames["iLinks"].document.getElementsByTagName("A");
x = 0;
//alert("x=0");
for (var i=0; i<links.length; i++)
{
var templink = links(i);
var onValues = templink.onclick + templink.onfocus + "";
if(onValues.indexOf("OnLink") >= 0)
{
linksArray[x] = templink;
x++;
}
}
for (var j=0; j<linksArray.length; 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.
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.createElement("IFRAME");
var linksArray = new Array();
var x = null;
hiddenIframe.id = "iLinks";
hiddenIframe.style.display = "none";
hiddenIframe.src = "source of links";
WebPart_WPQ_.appendChild(hiddenIframe);
links = frames["iLinks"].document.getElementsByTagName("A");
x = 0;
//alert("x=0");
for (var i=0; i<links.length; i++)
{
var templink = links(i);
var onValues = templink.onclick + templink.onfocus + "";
if(onValues.indexOf("OnLink") >= 0)
{
linksArray[x] = templink;
x++;
}
}
for (var j=0; j<linksArray.length; 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.