Solved

Window.focus - IE - Strange Problem

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now