Hi Everybody,

I need some hlep for my website. Whenever i will open my website one pop is required.

Can anyone tell me how to do.... please.

Thanks in Advance.
KavithaKesav

Recommended Answers

All 7 Replies

Insert this in the header section of your (x)HTML document(s).

<script type="text/javascript"> 
<!--
window.onload = function() { try {
window.open('yourdesiredpage.html','popup!'); } catch(e) { alert('Unable to open another window!'); } }
//-->
</script>

its not working...

Then this is another crossbrowser issue. You will need to add an eventListener in your onload event to make this work.

dont use a popup
popups are routinely blocked for security
every day a larger proportion of browsers have popup blockers enabled.
because popups are annoying
sites that use popups get worse results than those that do not

use a layer and show/hide it as necessary

Thanks for u r suggestion.

Can u tell me how to work on that.

The code below is a popup layer, for mozilla/firefox dom and IE dom, so you will see each action declared twice for the different DOM.
Its a script included in the pages for certain properties, I manage apartments and houses, creates a button that shows or hides a layer containing text onclick.
the layer/window remains in position on screen untill the viewer actually clicks 'close'.
class='top/bottom' in the script are just the color schemes of the layer, different to the site scheme so that it looks like a different window, described in the external css file, they werent necessary to put in for function

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01  Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<script language="javascript" type="text/javascript">
<!--
(document.getElementById) ? dom = true : dom = false;
function hideIt() {
 if (dom) {document.getElementById("layer1").style.visibility='hidden';}
 if (document.layers) {document.layers["layer1"].visibility='hide';} }
function showIt() {
 if (dom) {document.getElementById("layer1").style.visibility='visible';}
 if (document.layers) {document.layers["layer1"].visibility='show';} }
onResize="window.location.href = window.location.href"
//--></script>
</head>
<body>
<button align="center" onClick="showIt();">Important Information</button>
<div id="layer1" style="position:fixed; left:20px; width:45%; top:20px; visibility:hidden;"><!--Had to include the style from the ext sheet, else it would not be recognisable that this div will remain in place over the other layers until closed-->
<table border="0" cellspacing="0" cellpadding="3">
<tr>
<td Align="right" onClick="hideIt()" class="top">
<font Color="#ffffff"><Strong>Close</strong></font>
</td>
</tr>
<tr>
<td class="bottom">
<center><font size="+1"><b>Single Dwellings</b>:</font></center>
Tenants &amp; Residents of Single homes have different responsibilities to Tenants &amp; Residents of Multi Unit Residential Developments.
<UL compact>
<li>The tenant is required to have current adequate tenant insurance, determined by Dockrey&nbsp;Apartments, at all times.</li>
<li>The tenant is responsible for snow removal of their own approaches</li>
<li>The tenant is responsible for lawn and garden care of the property.</li>
<li>The tenant is responsible for properly sorting garbage and recyclables and appropriately placing for collection</li>
<li>The tenant is responsible for payment of Fuel and Electricity charges.</li>
</ul>
</td>
</tr>
<tr>
<td Align="right" onClick="hideIt()" class="top">
<font Color="#ffffff"><Strong>Close</strong></font>
</td>
</tr>
</table>
</div>
</body></html>

The actual php include is much smaller, headers et al are declared in the outer file.
Not blocked/blockable, totally configurable in css for position appearance.

Thanks for all, who are involved in this.

Finally i got some code, its solving my problem. Below the code

Just add this code in u r page or u can make a supparate page and give include file which page u want.

<SCRIPT type=text/javascript>
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all
var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")

function hidebox(){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
document.showimage.visibility="hide"
}

</SCRIPT>

</HEAD>
<style type="text/css">
<!--
body,td,th {
    font-size: 12px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
}
a:link {
    text-decoration: none;
}
a:visited {
    text-decoration: none;
}
a:hover {
    text-decoration: none;
}
a:active {
    text-decoration: none;
}
-->
</style><BODY>
<DIV id=showimage 
style="WIDTH:; POSITION: absolute; left: 300px; top: 250px; width: 336px;">
<TABLE cellSpacing=0 cellPadding=0 width=359 bgColor=#000080 border=0>
  <TR>
    <TD width="355" bgcolor="#FFFFFF"><TABLE width="100%" height=83 border=1 cellPadding=2 cellSpacing=0 bordercolor="#000000">
        <TR>
          <TD width="95%" bgcolor="#FF0000" class="sitehdlink" id=dragbar 
          style="CURSOR: pointer" onmousedown=initializedrag(event)>FocusMT Announcement</TD>
          <TD width="5%" bgcolor="#FF0000" style="CURSOR: hand"><A onClick="hidebox();return false" 
            href="#"><IMG src=images/anounceclose.gif height=14 width=16 border=0></A></TD>
        </TR>
        <TR valign="top">
          <TD height="61" colSpan=2 bgColor=#ffffff style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px"><table width="100%" border="0" cellspacing="0" cellpadding="2">
            <tr bgcolor="#FFFFE8">
              <td colspan="2" class="blkbold">New Policies Uploaded</td>
            </tr>
            <tr>
              <td width="177" height="5" colspan="1"></td>
            </tr>
            <tr>
              <td colspan="1"><table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
                  <tr>
                    <td width="6%" class="maincont">1.</td>
                    <td width="94%"><a href="sitemap.aspx" class="bodylink">Policy One</a></td>
                  </tr>
                  <tr>
                    <td class="maincont">2. </td>
                    <td><a href="sitemap.aspx" class="bodylink">Policy Two</a></td>
                  </tr>
                  <tr>
                    <td class="maincont">3.</td>
                    <td><a href="sitemap.aspx" class="bodylink">Policy One</a></td>
                  </tr>
                  <tr>
                    <td class="maincont">4. </td>
                    <td><a href="sitemap.aspx" class="bodylink">Policy Two</a></td>
                  </tr>

                  <tr>
                    <td height="5"></td>
                    <td height="5"></td>
                  </tr>
              </table></td>
            </tr>
          </table></TD>
        </TR>
    </TABLE>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.