Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

? firefox bookmarket script to list urls across frames

Status
Not open for further replies.

hydra3333

Technical User
Dec 23, 2009
1
AU
Hi, the following Firefox bookmarklet script is supposed to list URLs across frames, but produces nothing more than the heading, and the browser STOP button has to be pressed to stop it running. (Needless to say, as a bookmarlket it's all on one line). Any suggestions ?
Code:
javascript:(
function(){
function htmlEscape(s){
	s=s.replace(/&/g,'&');
	s=s.replace(/>/g,'>');
	s=s.replace(/</g,'<');
	return s;
} 
function attrQuoteEscape(s){
	s=s.replace(/&/g,'&'); 
	s=s.replace(/"/g, '"');
	return s;
} 
function ListLinksInDoc(doc){
	var z,i; 
	nD.writeln('<br><h3>Start of document</h3></br>'); 
	z = doc.links; 
	for (i = 0; i < z.length; ++i) { 
		nD.write(i);
		nD.write('. <a href="');
		nD.write(attrQuoteEscape(z[i].href));
		nD.write('">Inner HTML=');
		nD.write(z[i].innerHTML);
		nD.write(' href=');
		nD.write(htmlEscape(z[i].href));
		nD.writeln('</a><br>');
	} 
	nD.writeln('<br>End of document</br>'); 
}
function recurseFrames(doc, callback) {
	if (typeof callback != 'function') return;
	callback(doc);
	var frames = doc.getElementsByTagName("frame");
	for (var i = 0; i < frames.length; i++) {
		var d = frames[i].contentDocument;
		recurseFrames(d, callback);
	}
}
var nD = window.open().document; 
nD.writeln('<html><head><title>List of Links in Frames</title><base target="_blank"></head><body>'); 
nD.write('List of Links in Frames in <a href="'+attrQuoteEscape(location.href)+'">')
nD.write(htmlEscape(location.href))
nD.writeln('</a><br><br><hr><br>'); 
recurseFrames(top,ListLinksInDoc);
nD.writeln('<br><hr></body></html>'); 
nD.close(); 
}
)();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top