/    Sign up×
Community /Pin to ProfileBookmark

popup does work in FF, not in IE

Hi folks,

This function works great in FF, but in IE i get a runtime error on line 16 javascript error…. I don’t get why..

[code=php]<script language=”JavaScript”><!–
function newWindow(imagename, text) {

var newVar = imagename + “xxxxxx” + text;

msgWindow=open(‘imagepopup.asp’,newVar,’resizable=no,width=650,height=570,scrollbars=yes’);
if (msgWindow.opener == null) msgWindow.opener = self;
}
//–></script>[/code]

For example, I target this function using this link:
javascript:newWindow(document.getElementById(“image5”).src, “text description”)

Hope anyone know what’s wrong.. Line 16 is the line ‘msgWindow…. etc.’.

Regards,
roel

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@LogicianJul 14.2006 — 

var newVar = imagename + "xxxxxx" + text;

...

javascript:newWindow(document.getElementById("image5").src, "text description")
[/QUOTE]

I haven't tested this, but the parameter "text description" introduces a space into the window's name, which is not allowed.
Copy linkTweet thisAlerts:
@roel018authorJul 14.2006 — I haven't tested this, but the parameter "text description" introduces a space into the window's name, which is not allowed.[/QUOTE]

That seems to be the problem indeed. However, I'm trying to replace all the characters in the string I submit before opening the window, however, I can't seem to replace the slash character !!.. I use this code, and it works for every special character, expect the slash ! How can I replace the slash character ?? If I could fix this it would work !

[code=php]var imagename5 = imagename4.replace("/", "xslashx");
var imagename6 = imagename5.replace(":", "xdotsx");
var imagename7 = imagename6.replace("&#47;", "xslash2x");[/code]


As you see, both the "/" and the html character code "&#47;" doesn't work.... ?
Copy linkTweet thisAlerts:
@roel018authorJul 14.2006 — It works !!!! I used this:

[code=php]
<script language="JavaScript"><!--
function newWindow(imagename, text) {



var imagename1 = imagename.replace(/./gim, "xpuntx");
var imagename2 = imagename1.replace(/ /gim, "xspatiex");
var imagename2a = imagename2.replace(/%20/gim, "xspatie2x");
var imagename3 = imagename2a.replace(/-/gim, "xminx");
var imagename4 = imagename3.replace(/_/gim, "xunderscorex");
var imagename5 = imagename4.replace(///gim, "xslashx");
var imagename6 = imagename5.replace(/:/gim, "xdotsx");
var imagename7 = imagename6;

var text1 = text.replace(/./gim, "xpuntx");
var text2 = text1.replace(/ /gim, "xspatiex");
var text3 = text2.replace(/-/gim, "xminx");
var text4 = text3.replace(/_/gim, "xunderscorex");
var text5 = text4.replace(///gim, "xslashx");
var text6 = text5.replace(/:/gim, "xdotsx");
var text7 = text6;



//alert(escape(imagename));

//alert(imagename.replace(/http://(.*)//gim, "test"));
var newVar = imagename7 + "yyyyyy" + text7;

msgWindow=open('imagepopup.asp',newVar,'resizable=no,width=650,height=570,scrollbars=yes');
if (msgWindow.opener == null) msgWindow.opener = self;
}
//--></script>[/code]
×

Success!

Help @roel018 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...