/    Sign up×
Community /Pin to ProfileBookmark

javascript works in FF(12) not IE(8)

This bit of code works exactly like I want it to in FF but displays the dialog at the bottom of the page in IE. In FF it is a basic lightbox dialog box with Yes No buttons.

var confirmBox = {
message : ‘This is a Confirm Box’,
trueTxt : ‘True’,
complete : true,
re : ”,
falseTxt : ‘False’,
onTrue : ‘alert(“true”)’,
onFalse : ‘alert(“false”)’,
setTrue : function (ontrue) { this.onTrue = ontrue + “confirmBox.update(‘true’)”; },
setFalse : function (onfalse) { this.onFalse = onfalse + “confirmBox.update(‘false’)”; },
setTrueText : function (trueText ){ this.trueTxt = trueText; },
setFalseText : function (falseText) { this.falseTxt = falseText; },
setText : function (text) { this.message = text; },
hide : function () {
var bg = document.getElementById(‘___confirmBox_bg’);
var center = document.getElementById(‘_
__
confirmBox_center’);
var dialog = document.getElementById(‘___confirmBox_dilog’);
center.removeChild(dialog);
bg.removeChild(center);
document.body.removeChild(bg);
},
show : function () {
this.createBG();
this.createCenter();
this.createDialog();
},
update : function (sw) {
this.re = sw;
},
state : function () {
if(this.re == ”) {
return false;
}
else {
return this.re;
}
},
createBG : function () {
var bg = document.createElement(“div”);
bg.setAttribute(‘style’, “display: table; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80);”);
bg.setAttribute(‘id’, ‘_
__
confirmBox_bg’);
document.body.appendChild(bg);
},
createCenter : function () {
var center = document.createElement(‘div’);
center.setAttribute(‘style’,”#position: absolute; #top: 50%; display: table-cell; vertical-align: middle; margin-left:auto; margin-right:auto;”);
center.setAttribute(‘id’, ‘___confirmBox_center’);
document.getElementById(‘_
__
confirmBox_bg’).appendChild(center);
},
createDialog : function () {
var dialog = document.createElement(‘div’);
dialog.setAttribute(‘style’, “display:block; width: 300px; padding: 16px; background-color: white; z-index:1003; margin-left:auto; margin-right:auto;”);
dialog.setAttribute(‘id’, ‘___confirmBox_dilog’);
dialog.innerHTML = this.message + ‘<div align=”right”><input type=”button” onclick=”eval(confirmBox.onTrue); confirmBox.hide();” value=”‘ +this.trueTxt + ‘” /><input type=”button” onclick=”eval(confirmBox.onFalse); confirmBox.hide();” value=”‘ + this.falseTxt + ‘” /></div>’;
document.getElementById(‘_
__
confirmBox_center’).appendChild(dialog);

}
}

//the javascript above is in an external script and the use of the object is down below.

confirmBox.setText(‘This is my dialog message.’); //Sets the text to show in the box
confirmBox.setTrueText(“Yes”); // sets the text on the return true button
confirmBox.setFalseText(“No”); // sets the text on the return false button
confirmBox.setTrue(‘function(“‘ + q + ‘”);’); //what to do when true is clicked
confirmBox.setFalse(‘checkData(“‘ + q + ‘”);’);// what to do when false is clicked
confirmBox.show(); // Show the confirmBox

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@krieghoff81authorMay 04.2012 — I basically made a statement above. I would like to make this work the same in IE if at all possible. I would appreciate any help. Thanks
×

Success!

Help @krieghoff81 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.6,
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,
)...