Solved

Window.focus - IE - Strange Problem

Posted on 2006-06-28
5
327 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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