Show DHTML popup window in front of frames/enable disabled/read-only text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rahaman sharif
    New Member
    • Sep 2007
    • 6

    Show DHTML popup window in front of frames/enable disabled/read-only text box

    Hi All,

    I have some problem in innerHtml. I have the textbox in innerHtml, In the innerHtml textbox was read only. I want make it to enable. if user enter the text that text will be retrieved, so i want to be enable text box. Another one problem is the the innerhtml will be in like popup window. it will automatically closed.i want be whenever i click close button that time only it will close. Please help me.

    here is the Code


    [HTML]<html>

    <body>
    <script type="text/javascript">
    function show_popup23()
    {

    var p=window.create Popup();
    var pbody=p.documen t.body;
    //pbody.style.fil ter="alpha(opac ity=100)" ;
    pbody.style.fon tSize="10px";
    pbody.style.ali gn="center";
    pbody.style.fon tFamily="Verdan a, Arial, Helvetica, sans-serif";
    pbody.document. body.innerHTML= oToolTip.innerH TML;
    p.show(0,0,800, 500,document.bo dy);

    }
    </script>

    <a onClick="show_p opup23()">Click Me</a>
    <div id="oToolTip" style="display: none; ">
    <div id="block" style=" vertical-align:middle; width:100%; height:100%; border:2px solid black; filter:progid:D XImageTransform .Microsoft.Grad ient(GradientTy pe=0, StartColorStr=# cdcdcd, EndColorStr=#FF FFFF); padding:0px">

    <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0" bordercolor="00 0000" align="center" class="txttype1 " >
    <tr bgcolor="#9B9AB 7"><td colspan="4" height="1px"></td></tr>

    <tr><td align="center" valign="middle" >
    <table class="txttype1 " border="0" bordercolor="#0 00000" cellpadding="0" cellspacing="0" >
    <tr>
    <td bgcolor="#9B9AB 7" width="1px"></td>
    <td height="22px" width="150px">< font size="1px" face="Verdana, Arial, Helvetica, sans-serif">Headeing </font></td>
    <td align="right">< a onclick="pbody. hide()"><img src="images/close.gif"></a></td>
    <td bgcolor="#9B9AB 7" width="1px"></td>
    </tr>
    <tr>
    <td bgcolor="#9B9AB 7" width="1px"></td>
    <td bgcolor="#fffff f" height="25px">< font size="1px" face="Verdana, Arial, Helvetica, sans-serif">Enter the Name</font></td>
    <td bgcolor="#fffff f"><input type="text" class="textbox" name="name" value="sadas" /> </td>
    <td bgcolor="#9B9AB 7" width="1px"></td></tr>
    <tr>
    <td bgcolor="#9B9AB 7" width="1px"></td>
    <td bgcolor="#fffff f" colspan="2" align="center" height="40px">< input type="submit" value="Done" name="done" ><input type="reset" value="Clear" name="clear" > </td>
    <td bgcolor="#9B9AB 7" width="1px"></td>
    </tr>
    <tr bgcolor="#9B9AB 7"><td colspan="4" height="1px"></td></tr>
    </table>
    </td></tr>
    </table>
    </div>
    </div>
    </body></html>[/HTML]
    Last edited by acoder; Jul 14 '08, 08:59 AM. Reason: Added [code] tags
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    What is createPopup? Either you need to define this function, or you would need to use window.open instead. And same goes for show.

    And you can't refer to oToolTip like this. You need to add this statement to your code:[CODE=javascript]var oToolTip = document.getEle mentById('oTool Tip');[/CODE]

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      I would add that the alternative to createPopup() would be a DHTML popup window. Although those suggestions may not answer your question directly, they will help you out in the long run. You're coding only for one browser using proprietary code which will not work in any other browser. Get out of that habit as soon as possible as the other browsers are taking a larger share of the market year in year out.

      Re. your question: I can't see the text box as being read-only in your code.

      PS. please use code tags when posting code.

      Comment

      • Rahaman sharif
        New Member
        • Sep 2007
        • 6

        #4
        Originally posted by hsriat
        What is createPopup? Either you need to define this function, or you would need to use window.open instead. And same goes for show.

        And you can't refer to oToolTip like this. You need to add this statement to your code:[CODE=javascript]var oToolTip = document.getEle mentById('oTool Tip');[/CODE]

        Hi i dont want to window.open because it will display close,min and disable max button on title bar i dont want to like that. i have morethen 8 frame in a page so i want top of the frame(over the frame). i used like that, in the case the problem is if i click outside the popup it automatically closed.i want to whenever i click the close button that time only it closed. please help me.

        Did you know div tag over the frame. it is possible. If u know means tell me how to do that.

        Thanks

        Comment

        • hsriat
          Recognized Expert Top Contributor
          • Jan 2008
          • 1653

          #5
          Originally posted by Rahaman sharif
          Hi i dont want to window.open because it will display close,min and disable max button on title bar i dont want to like that. i have morethen 8 frame in a page so i want top of the frame(over the frame). i used like that, in the case the problem is if i click outside the popup it automatically closed.i want to whenever i click the close button that time only it closed. please help me.

          Did you know div tag over the frame. it is possible. If u know means tell me how to do that.

          Thanks
          Then use a DHTML popup script like lightbox or thickbox. Just google for either of them and see what you get.

          Comment

          • Rahaman sharif
            New Member
            • Sep 2007
            • 6

            #6
            Originally posted by hsriat
            Then use a DHTML popup script like lightbox or thickbox. Just google for either of them and see what you get.
            No yar. I cant use gray box, light box and thick box. In this window have 2 fields only. so i want simple. if you know the div tag over the frame. please tell me how to do that. that is very help full for me.

            Thanks yar.

            Comment

            • hsriat
              Recognized Expert Top Contributor
              • Jan 2008
              • 1653

              #7
              Originally posted by Rahaman sharif
              No yar. I cant use gray box, light box and thick box. In this window have 2 fields only. so i want simple. if you know the div tag over the frame. please tell me how to do that. that is very help full for me.

              Thanks yar.
              Then you create a popup div. The CSS that is required for a popup div are as follows:[code=css]#popup_div {
              position: fixed; /* (or absolute) */
              left: 0px;
              top: 200px;
              height: 200px;
              width: 400px;
              display: none;
              z-index: 200;
              background-color: #fff;
              }[/code]
              And make you popUp() function like:
              [code=javascript]function popUp(txt) {
              var popup = document.getEle mentById('popup _div');
              popup.innerHTML = txt;
              popup.style.lef t = (parseInt(scree n.availWidth) - 400) /2 + 'px';
              popup.style.dis play = 'block';
              }[/code]

              Comment

              • Rahaman sharif
                New Member
                • Sep 2007
                • 6

                #8
                Originally posted by hsriat
                Then you create a popup div. The CSS that is required for a popup div are as follows:[code=css]#popup_div {
                position: fixed; /* (or absolute) */
                left: 0px;
                top: 200px;
                height: 200px;
                width: 400px;
                display: none;
                z-index: 200;
                background-color: #fff;
                }[/code]
                And make you popUp() function like:
                [code=javascript]function popUp(txt) {
                var popup = document.getEle mentById('popup _div');
                popup.innerHTML = txt;
                popup.style.lef t = (parseInt(scree n.availWidth) - 400) /2 + 'px';
                popup.style.dis play = 'block';
                }[/code]
                Thanks hsriat for your effort but i think u miss understood my query , let me explain my query !! i have an application running in 8 frames, what i require is on click of a button in say frame3 i need a div tag to be windowed like modal dialog box so that the user can enter some inputs , i can't use a modal dialog box. so if you could tell me how is it possible to show a div over all frames in the center of I.E it would be great !! many a thanks again for your replys

                Comment

                • hsriat
                  Recognized Expert Top Contributor
                  • Jan 2008
                  • 1653

                  #9
                  Didn't the above code work?

                  Comment

                  • Rahaman sharif
                    New Member
                    • Sep 2007
                    • 6

                    #10
                    Originally posted by hsriat
                    Didn't the above code work?
                    No yar. i tried but i will work in the that frame only. I want like this

                    Code:
                     ----------------------------------------
                     |                                             |
                     |           Upper frame                |
                     |                                             |
                     |           -------------------               |
                     |          |      DIV          |             |
                     ---------     Middle frame   -----------|
                     |         |                       |             |
                     |         --------------------                 |
                     |                                              |
                     |          Lower frame                  |
                     |                                             |
                     ----------------------------------------------
                    In this div will appear in three frame (upper, Middle and Lower frame). I want to like this.

                    Thanks yar

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      For modal dialogs, you could use showModalDialog if you know that your clients use IE, Firefox 3 and the latest versions of Safari. Opera and Firefox2- don't support it.

                      For a more cross-browser solution, show the DHTML div from the frameset, i.e. using top to get to the parent. For a modal effect, use a transparent layer which doesn't allow the user to interact with the rest of the content until they close the popup div. To give you an idea, see this link.

                      Comment

                      • hsriat
                        Recognized Expert Top Contributor
                        • Jan 2008
                        • 1653

                        #12
                        Originally posted by Rahaman sharif
                        No yar. i tried but i will work in the that frame only. I want like this
                        In this div will appear in three frame (upper, Middle and Lower frame). I want to like this.

                        Thanks yar
                        Well Well, I see that div is not being created in the frameset, even if created for window.top.docu ment. And if created from within a frame, it takes references of that frame as position coordinates.

                        So here, if possible you can create it from the middle frame. Do you consider it as an option?
                        Originally posted by acoder
                        For a more cross-browser solution, show the DHTML div from the frameset, i.e. using top to get to the parent. For a modal effect, use a transparent layer which doesn't allow the user to interact with the rest of the content until they close the popup div. To give you an idea, see this link.
                        [html]<html>
                        <head>
                        <script type="text/javascript">
                        window.onload = function () {
                        var bt = document.getEle mentsByTagName( 'button')[0];
                        bt.onclick = function () {
                        var p = window.top.docu ment.createElem ent('div');
                        //p.className = 'popup_div';
                        //p.id = 'popup_div';
                        p.innerHTML = 'Name:<br /><input type="text" name="name" /><br />Surname:<br /><input type="text" name="surname"> ';
                        //p.style.left = (parseInt(scree n.availWidth) - 400) /2 + 'px';
                        //p.style.display = 'block';
                        try {
                        window.top.docu ment.getElement ById('top_frame set').appendChi ld(p); //not working
                        //alert(window.to p.document.getE lementById('top _frameset').id) //working
                        }
                        catch (e) {alert(e);}
                        //not showing any error
                        //neither is firebug showing any
                        //but the web development tool bar's CSS error icon is turning red
                        //Error console says nothing.
                        }
                        }
                        </script>
                        </head>
                        <body>
                        <div>
                        <h1>Page 3</h1>
                        <button>Show PopUp</button>
                        </div>
                        </body>
                        </html>[/html]This is the code of one of the three frames but isn't working.

                        PS: I think the title should be changed.

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #13
                          I have changed the title.

                          I hadn't tested the concept of using a DHTML div popup in a frameset (I don't like frames anyway), it was an idea. I would avoid frames and either use iframes or load the external content in divs dynamically using DHTML or Ajax.

                          Comment

                          Working...