469,642 Members | 1,195 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,642 developers. It's quick & easy.

help translate IE to firefox

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[i].src.indexOf(siteURL) != -1) {
n++;
for (k = 0; k < func.length; k++)
func[k](iframes[i]);
}
}
}
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;
}
}
}
Sep 11 '05 #1
1 1387
"doug s" <skyriverfly @ yahoo.com> writes:
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[i].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[i]);
}
}
}
return n;
}

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


"id" is a global variable?
Good luck.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Sep 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by bobueland | last post: by
1 post views Thread by Nestor | last post: by
bvdet
9 posts views Thread by bvdet | last post: by
9 posts views Thread by Chrissy | last post: by
reply views Thread by alaa123 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.