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
Solved

Control contains javascript not working on IE as firefox

Posted on 2007-11-20
5
391 Views
Last Modified: 2013-11-19
I created an Asp.Net user control which supposed to slide from the very bottom of the page to a up a little.

It works fine as i want on Firefox but its not sliding at all in IE, it just show in the final point on IE.

please take a look at the control code and the method i used to call it from another page "default.aspx page".
and tell me whats wrong i did


Thanks,
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PopUp.ascx.cs" Inherits="PopUp" %>
 
<script language="javascript" type="text/javascript">
 
var X = 0;
var Y = 0;
    function set(title,message,x,y,time)
    {
       X = x;
       Y = y;
       document.getElementById("popup").style.visibility = 'visible' ;
       document.getElementById("popup").style.zIndex=120000;
       document.getElementById("title").innerHTML = title; //'<div style="padding-top: 0px; padding-left: 170px;"><a href="javascript:HidePopUp();">close</a></div>' + 
       document.getElementById("message").innerHTML =message;
 
var height = (document.all) ? document.body.clientHeight+ 30 : window.innerHeight + 30;
//var width = (document.all) ? document.body.clientWidth : window.innerWidth;
       document.getElementById("popup").style.left=x+'px';
       document.getElementById("popup").style.top= height+'px';//document.body.style.height;//y+20+'px';
       doMove();
       
       var t=setTimeout("HidePopUp()",time)
    }
 
 
    function doMove() 
    {
         document.getElementById("popup").style.top = (parseInt(document.getElementById("popup").style.top)-0.5)+'px'; 
         if(parseInt(document.getElementById("popup").style.top) > Y)
            setTimeout(doMove,2); // call doMove() in 2 msec
    }
        
    function HidePopUp()
    {
      document.getElementById("popup").style.visibility = 'hidden' ;
    }
    
</script>
 
<div id="popup" style="top: 0px; left: 0px; height: 60px; width: 200px; position: absolute;
    visibility: hidden; border-right: black thin solid; border-top: black thin solid;
    border-left: black thin solid; border-bottom: black thin solid; background-color:Fuchsia;">
    <div id="title" style="font: bold 8px verdana; padding-top: 0px; padding-left: 0px;">
        <!--<div style="padding-top: 0px; padding-left: 170px;">
            <a href="javascript:HidePopUp();">close</a>
        </div>-->
    </div>
    <div id="message" style="font: bold 12px verdana;">
    </div>
</div>
 
 
 
 
'--------------------------------------------
I CALL IT WITH THIS CODE:
'--------------------------------------------
 
<input type="button" onclick="javascript:set('Hi','This is Me',parseInt(document.body.clientWidth)-210,parseInt(document.body.clientHeight)+35,5000);" value="set value" />

Open in new window

0
Comment
Question by:AmrNet
  • 3
  • 2
5 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 125 total points
ID: 20322593
When I tried it, it didn't show at all. You set it to move five pixels, from one position outside the window to another positon outside the window.

A timeout of 2 milliseconds is totally off for something that is showing something on the screen. That is about ten times the update rate of your screen, so your are doing a lot of movement that noone ever will be able to see. You should use something closer to the update rate of the screen.

Moving an element half a pixel is pointless. The value will just be rounded when it's displayed. Also, as you used parseInt to read the value, the fraction part would be discarded when you read it.

If you keep the position of the element in a variable, you don't have parse the style to get the position of the element.

I added a parameter to the set function to specify the maximum movement distance, and changed the x and y parameters to specify the size of the element instead.
<script type="text/javascript">
 
function $(id) { return document.getElementById(id); }
 
var targetY, currentY;
 
function set(title,message,w,h,move,time) {
   var x = document.body.clientWidth - w;
   currentY = document.body.clientHeight - h;
   targetY = currentY - move;
   $('popup').style.visibility = 'visible' ;
   $('popup').style.zIndex = 120000;
   $('title').innerHTML = title;
   $('message').innerHTML =message;
   $('popup').style.left = x + 'px';
   doMove();
   window.setTimeout('HidePopUp()', time)
}
 
function doMove() {
   $('popup').style.top = currentY + 'px';
   currentY-=1;
   if (currentY > targetY) {
      window.setTimeout('doMove()', 30); // call doMove() in 30 msec
   }
}
        
function HidePopUp() {
   $('popup').style.visibility = 'hidden' ;
}
 
</script>
 
<div id="popup" style="top: 0px; left: 0px; height: 60px; width: 200px; position: absolute;
    visibility: hidden; border: black 1px solid; background-color:Fuchsia;">
    <div id="title" style="font: bold 8px verdana; padding-top: 0px; padding-left: 0px;">
        <!--<div style="padding-top: 0px; padding-left: 170px;">
            <a href="javascript:HidePopUp();">close</a>
        </div>-->
    </div>
    <div id="message" style="font: bold 12px verdana;">
    </div>
</div>
 
<input type="button" onclick="set('Hi','This is Me', 210, 70, 350, 5000);" value="set value" />

Open in new window

0
 

Author Closing Comment

by:AmrNet
ID: 31410184
You are perfect man :)
Thanks
0
 

Author Comment

by:AmrNet
ID: 20331364
please can you take a look at this question its about the same thing:

http://www.experts-exchange.com/index.jsp?qid=22976552

Thanks
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20331720
No, I can't. The link only takes me to the startpage of EE.
0
 

Author Comment

by:AmrNet
ID: 20331760
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Load data upon clicking a button 8 34
binding event to form in window.open 9 35
Implement a function similar to grep in vanilla Javascript 3 18
jQuery force form POST 7 44
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

809 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