By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

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

P: 6
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.createPopup();
var pbody=p.document.body;
//pbody.style.filter="alpha(opacity=100)" ;
pbody.style.fontSize="10px";
pbody.style.align="center";
pbody.style.fontFamily="Verdana, Arial, Helvetica, sans-serif";
pbody.document.body.innerHTML=oToolTip.innerHTML;
p.show(0,0,800,500,document.body);

}
</script>

<a onClick="show_popup23()">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:DXImageTransform.Microsoft.Gradient( GradientType=0, StartColorStr=#cdcdcd, EndColorStr=#FFFFFF); padding:0px">

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

<tr><td align="center" valign="middle">
<table class="txttype1" border="0" bordercolor="#000000" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#9B9AB7" 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="#9B9AB7" width="1px"></td>
</tr>
<tr>
<td bgcolor="#9B9AB7" width="1px"></td>
<td bgcolor="#ffffff" height="25px"><font size="1px" face="Verdana, Arial, Helvetica, sans-serif">Enter the Name</font></td>
<td bgcolor="#ffffff"><input type="text" class="textbox" name="name" value="sadas" /> </td>
<td bgcolor="#9B9AB7" width="1px"></td></tr>
<tr>
<td bgcolor="#9B9AB7" width="1px"></td>
<td bgcolor="#ffffff" colspan="2" align="center" height="40px"><input type="submit" value="Done" name="done" ><input type="reset" value="Clear" name="clear" > </td>
<td bgcolor="#9B9AB7" width="1px"></td>
</tr>
<tr bgcolor="#9B9AB7"><td colspan="4" height="1px"></td></tr>
</table>
</td></tr>
</table>
</div>
</div>
</body></html>[/HTML]
Jul 14 '08 #1
Share this Question
Share on Google+
12 Replies


hsriat
Expert 100+
P: 1,654
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:
Expand|Select|Wrap|Line Numbers
  1. var oToolTip = document.getElementById('oToolTip');
Jul 14 '08 #2

acoder
Expert Mod 15k+
P: 16,027
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.
Jul 14 '08 #3

P: 6
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:
Expand|Select|Wrap|Line Numbers
  1. var oToolTip = document.getElementById('oToolTip');

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
Jul 15 '08 #4

hsriat
Expert 100+
P: 1,654
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.
Jul 15 '08 #5

P: 6
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.
Jul 15 '08 #6

hsriat
Expert 100+
P: 1,654
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:
Expand|Select|Wrap|Line Numbers
  1. #popup_div {
  2.     position: fixed; /* (or absolute) */
  3.     left: 0px;
  4.     top: 200px;
  5.     height: 200px;
  6.     width: 400px;
  7.     display: none;
  8.     z-index: 200;
  9.     background-color: #fff;
  10. }
And make you popUp() function like:
Expand|Select|Wrap|Line Numbers
  1. function popUp(txt) {
  2.     var popup = document.getElementById('popup_div');
  3.     popup.innerHTML = txt;
  4.     popup.style.left = (parseInt(screen.availWidth) - 400) /2 + 'px';
  5.     popup.style.display = 'block';
  6. }
Jul 15 '08 #7

P: 6
Then you create a popup div. The CSS that is required for a popup div are as follows:
Expand|Select|Wrap|Line Numbers
  1. #popup_div {
  2.     position: fixed; /* (or absolute) */
  3.     left: 0px;
  4.     top: 200px;
  5.     height: 200px;
  6.     width: 400px;
  7.     display: none;
  8.     z-index: 200;
  9.     background-color: #fff;
  10. }
And make you popUp() function like:
Expand|Select|Wrap|Line Numbers
  1. function popUp(txt) {
  2.     var popup = document.getElementById('popup_div');
  3.     popup.innerHTML = txt;
  4.     popup.style.left = (parseInt(screen.availWidth) - 400) /2 + 'px';
  5.     popup.style.display = 'block';
  6. }
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
Jul 15 '08 #8

hsriat
Expert 100+
P: 1,654
Didn't the above code work?
Jul 15 '08 #9

P: 6
Didn't the above code work?
No yar. i tried but i will work in the that frame only. I want like this

Expand|Select|Wrap|Line Numbers
  1.  ----------------------------------------
  2.  |                                             |
  3.  |           Upper frame                |
  4.  |                                             |
  5.  |           -------------------               |
  6.  |          |      DIV          |             |
  7.  ---------     Middle frame   -----------|
  8.  |         |                       |             |
  9.  |         --------------------                 |
  10.  |                                              |
  11.  |          Lower frame                  |
  12.  |                                             |
  13.  ----------------------------------------------
  14.  
In this div will appear in three frame (upper, Middle and Lower frame). I want to like this.

Thanks yar
Jul 15 '08 #10

acoder
Expert Mod 15k+
P: 16,027
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.
Jul 15 '08 #11

hsriat
Expert 100+
P: 1,654
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.document. 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?
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.getElementsByTagName('button')[0];
bt.onclick = function () {
var p = window.top.document.createElement('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(screen.availWidth) - 400) /2 + 'px';
//p.style.display = 'block';
try {
window.top.document.getElementById('top_frameset') .appendChild(p); //not working
//alert(window.top.document.getElementById('top_fram eset').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.
Jul 15 '08 #12

acoder
Expert Mod 15k+
P: 16,027
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.
Jul 16 '08 #13

Post your reply

Sign in to post your reply or Sign up for a free account.