www.webdeveloper.com
Results 1 to 2 of 2

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

  1. #1
    Join Date
    May 2012
    Posts
    2

    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

  2. #2
    Join Date
    May 2012
    Posts
    2
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles