Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Window.focus - IE - Strange Problem

Posted on 2006-06-28
5
Medium Priority
?
344 Views
Last Modified: 2008-03-17
Hello All

I'm having very strange problems with window focus in internet explorer.

1.  I've my default.aspx and in that I'm opening a new asp page called  Edi.aspx using
      Dim jscriptStr As String
                jscriptStr = "<script language=JavaScript> window.open('Edi.aspx','editorWin','height=5,width=555,left=300,top=300,toolbar=0,location=0, directories=0,status=0,menubar=0,scrollbars=no,resizable=0,titlebar=no');</script>"
                RegisterClientScriptBlock("clientScript", jscriptStr)

 In the Edi.aspx body tag I'm putting onload="javascript:top.focus();".

This is not working and the Edi.aspx is hiding behind the default.aspx. why is this happening? At the same time when I used this technique for a opening different page other.aspx its working.

Another big thing is- the above technique is working perfectly fine in firefox browser for both Edi.aspx and other.aspx.

I'm using IE.6.0.


2. Is there any way to access the controls in Edi.aspx from the default.aspx ( here Edi.aspx is opened from the default.aspx using window.open('Edi.aspx'))?


Thanks for your help
Aditya
0
Comment
Question by:adityaiiii
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
deanvanrooyen earned 2000 total points
ID: 17005940
1 -  try remove ="javascript:top.focus();" from the body, are you trying to make the pop window modal?


2 - I think you mean this? or if you want it the other way round use the query string to pass params :
one way to do this is with javascript (if you use server.transfer there are other ways)
I have a default.aspx page with a textbox and hyperlink to pop a window edi.aspx, notice the javascript function popper - it tells the pop window what control to set:
default.aspx
<%@ Page Language="C#"  AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <link type="text/css" href="StyleSheet.css" media="all" rel="Stylesheet" />
    <style type="text/css">

   
    </style>
    <script type="text/javascript">

function popper(strField)
{
                        window.open('edi.aspx?field=' + strField ,'Popup','width=300,height=190');
}

</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" Height="20px" Width="155px"></asp:TextBox>
        <a href="javascript:;" onclick="popper('TextBox1');" title="Pick Date from Calendar">pop window</a>
    </div>
                              
    </form>
</body>
</html>

edit.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Edi.aspx.cs" Inherits="Edi" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body  bgcolor="black">
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Close" /></div>
    </form>
</body>
</html>

code behind edi cs

    protected void Button1_Click(object sender, EventArgs e)
    {
        string js = "<script type=\"text/javascript\">window.opener.form1.elements('" + Request.QueryString["field"] + "').value = '" + this.TextBox1.Text + "' ;this.window.close();</script>";

        Response.Write(js);
    }

this closes the popup and sets the text box on default.aspx to the text from the pop up window

this will should give you some starting points....

0
 
LVL 10

Expert Comment

by:SystemExpert
ID: 17006797
Hi,

You try like this

var newwindow;
function poptastic(url)
{
      newwindow=window.open(url,'name','height=400,width=200');
      if (window.focus) {newwindow.focus()}
}

or see thwe link

http://www.yourhtmlsource.com/javascript/popupwindows.html

Thanks
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17161348
try atlas it has an excellent modul window
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question