help translate IE to firefox

D

doug s

i have a code snippet i pasted below, which works in IE, but not in firefox.
any help would be really appreciated. thanks.


<script language="JavaScript">
var url = external.menuArguments.document.URL;

// iterate over all iframes in given document and apply functions.
function visitFrames(doc, func)
{
var siteURL = "mysite.com";
var iframes = doc.all.tags("IFRAME");
var n = 0;

if (iframes != null) {
for (i = 0; i < iframes.length; i++) {
if (iframes.src.indexOf(siteURL) != -1) {
n++;
for (k = 0; k < func.length; k++)
func[k](iframes);
}
}
}
return n;
}

function getCode(ifr) {
var p = "name=";
var l = p.length;
var s = ifr.src;
var i = s.indexOf(p);
if (i != -1) {
i += l;
c = s.substr(i);
j = c.indexOf('&');
if (j != -1) {
id = c.substring(0,j);
} else {
id = c;
}
}
}
 
L

Lasse Reichstein Nielsen

doug s said:
i have a code snippet i pasted below, which works in IE, but not in firefox.
any help would be really appreciated. thanks.
<script language="JavaScript">

Should be:
<script type="text/javascript">
The type attribute is required by HTML 4+ and is sufficient for all
browsers.
var url = external.menuArguments.document.URL;

I don't know what this does. It's definitly a proprietary IE feature.
....
Ok, MSDN says that it only works for scripts called from a custom
context menu entry. That might not be something you can do in Mozilla,
or other browsers.
// iterate over all iframes in given document and apply functions.
function visitFrames(doc, func)
{
var siteURL = "mysite.com";
var iframes = doc.all.tags("IFRAME");

The document.all is a proprietary IE feature. While Mozilla has recently
implemented it, there is still no reason to use it when the DOM methods
work just as well.

var iframes = doc.getElementsByTagName("IFRAME");
var n = 0;

if (iframes != null) {

if (iframes.length == 0) {
for (i = 0; i < iframes.length; i++) {

Remember to declare i as a local variable:

for (var i = 0; i < iframes.length; i++) {
if (iframes.src.indexOf(siteURL) != -1) {
n++;
for (k = 0; k < func.length; k++)


I assume "func" is an array declared elsewhere, which contains
at least the "getCode" function.
func[k](iframes);
}
}
}
return n;
}

function getCode(ifr) {


Nothing IE specific in this function.
id = c.substring(0,j);

"id" is a global variable?


Good luck.
/L
 

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
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top