views:

23

answers:

1

I have code that generates SVG that was developed for IE and the Adobe SVG Viewer. The Adobe SVG Viewer has a custom function called browserEval (see http://www.xml.com/lpt/a/994) that is being used to cause the browser to eval a window.open() call. This doesn't work in Chrome's native SVG renderer (and I haven't tried Firefox).

How can I rewrite this popup function to work properly in all modern SVG-supporting browsers? This original one works in IE but not Chrome:

function popUp(loc) { 
    browserEval("window.open('"+loc+"','_blank', 
        'width=1000,height=780,scrollbars=yes,resizable=yes, 
        status=no,toolbar=no,menubar=no,location=no')");
}

I tried this which works in Chrome but causes an error about number of arguments in IE:

var browserEvalCrossBrowser = (typeof(browserEval)=='undefined') ?
    function(x) { eval(x); } : browserEval;

function popUp(loc) { 
    browserEvalCrossBrowser("window.open('"+loc+"','_blank',
        'width=1000,height=780,scrollbars=yes,resizable=yes,
        status=no,toolbar=no,menubar=no,location=no')");
}
A: 

It looks like you are missing a single quote before the word "width", which is a syntax error.

Aside from that, apparently there is a bug in browserEval that causes this error (http://tech.dir.groups.yahoo.com/group/svg-developers/message/9063). Have you tried function(x) { browserEval(x); } instead of browserEval?

idealmachine
@idealmachine: That's a transcription error, it was correct in the code. Thanks for pointing it out, I'll correct it.
Scott Stafford