?
Solved

Window.focus - IE - Strange Problem

Posted on 2006-06-28
5
Medium Priority
?
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

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…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

719 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