ScrollIntoView Possible Onload ?
May 17, 2010Is it possible to use scrollIntoView onload? I know how to use it onclick, but I can not find out how to use it onload. Is it possible? And if it is, what would be the correct syntax?
View 3 RepliesIs it possible to use scrollIntoView onload? I know how to use it onclick, but I can not find out how to use it onload. Is it possible? And if it is, what would be the correct syntax?
View 3 RepliesI working on a project for a client and I need a javascript event to fire the scrollIntoView method to pan the browser to a DIV element at the bottom of the page.
My function is as follows:-
Code JavaScript:
function jumpToOtherProducts()
{
var x = document.getElementById("product_canvas");
x.scrollIntoView(true);
}
Ive tested this in FF, Chrome and Safari and works fine, but not IE8. what I can do about this?
I've got a text area with a vertical scrolldown bar. Using the following JS code the text area scrolls down as I'd expect:
document.getElementById(ID GOES HERE).scrollIntoView(true);
But the main are also scrolls down - is there any way to stop the main page scrolling down too?
I'm having a hard time figuring out why the onload event is not being
called for the frameset window in the following simple example. It is
being called for each of the component frames. Code:
I wander what gets loaded the fastest (1-2 or 3) in what succession:
<head>
<script type="text/javascript">
function andAction() {
// doing stuff
}
</script>
</head>
<body onload="andAction();">
<script type="text/javascript">andAction()</script></body>
just in the head and nothing more
This I am sure off:
<head>
<script type="text/javascript">
window.onload = function andAction() {
// doing stuff
}
</script>
</head>
<script type="text/javascript">andAction()</script></body>
just in the head and nothing more (should be 1)
Third and last which is faster:
body onload or window.onload
I found a problem while "scrolling into view" and to overcome this I made a function to simulate javascript's function. I would like to share it and here it is:
function alternativeScrollIntoView(parentDiv,elementIntoDiv )
{
var principal =parentDiv;
principal.scrollTop = 0;
var rects = principal.getClientRects()[0];
var topFinal = rects.top;
var bottomFinal = rects.bottom;
var bottomActual = elementIntoDiv.getClientRects()[0].bottom;
if (bottomActual == 0)
{
return;
}
while(bottomActual>bottomFinal||bottomActual<topFinal)
{
var direction="down";
if(bottomActual<topFinal) direction="up";
principal.doScroll(direction);
bottomActual=elementIntoDiv.getClientRects()[0].bottom;
}}
It worked in my enviroment, i hope it could be useful for you too.
I'm seeing a difference in behaviour between
window.onload = f();
and
<body onload="f();">
Specifically, window.onload appears to fire before all the elements of
the page have been rendered. As the difference is consistent across
IE/Moz/Opera, I'm assuming it's deliberate - can anyone point me
towards where this behaviour of window.onload is defined in the
documentation? TIA. Code:
Say I have serveral controls, all of which need to emit clientside script to
execute on page load. They can't emit to OnLoad = <functionname> because
then only one of the scripts will get executed. Is there a way around this?
there is a Onload that happens when I refresh a page and I get an
Alert() as debug thinkg but the alert() doesn't happen when I delete a
record using a link on the same page!
Why? any idea?
I have two functions that need to run when the page is open. I cannot combine them making one single function as from the one depends the further working of the page.
I tried oninit eventhandler (one function i put in onload event while the another one i put in the oninit) but the function from oninit handler was not fired.
I need to execute a JavaScript function "onload". The only problem is I
don not have access to the <body> tag as it is a part of the standard
page-header include (a separate file). How could I have certain pages
execute my function() onLoad?
The function basically just sets the original values of fields so that I
can determine if a field has been changed or not, which aleviates unnec.
sql update on the backend..
I thought that if I have:
....
<body onload="some_script();">
....
that some_script would not be called until the <body> was completely
loaded - is this not the case? With Safari 1.3 I seem to have to delay
inside some_script (there is some php in the <body> that slows down the
loading). Since I happen to have a spare iframe in my <body>, I load a
tiny bit of html in it whose job is simply to set a "loaded" flag,
tested inside my delay code.
What I was observing was that some fields inside a <form> in the <body>,
whose values are set by some_script, were, with Safari, not visible
until I clicked in one of them - then they all popped into sight. I
wasn't seeing this with other browsers and a delay mechanism fixed it.
It was as if the onload was triggered as soon as it was encountered
rather than when the loading was complete.
i wish the html to submit the form once it is loaded. what should be the code here (alert("how 's the code here"))? Code:
View 2 Replies View RelatedIs it just me or did something change?
The following works under IE but not FF:
function window.onload() {
alert(0);
}
The following works under both IE and FF:
window.onload = function() {
alert(0);
}
I'm using Firefox 1.5.0.3.....
I havent used java that much, and lately I updated from M$ java to SUN
(due to my bank).
Before, this worked:
<body onload="SetFocus(); window.focus();">
now, it does not. SetFocus() is included as:
<script language="JavaScript" src="mystuff.js"></script>
Though, this gives an alert:
<body onload="SetFocus(); window.focus();alert('hello')">
What is the difference and the trick here?
Why doesn't this seem to work?
var win;// window handle
function onloadfunction( arg ){// replace cnn with google
win.navigate( "http://www.google.com" );// never executes
}
win = window.open("http://www.cnn.com", "win", ""); // open window
with CNN
win.onload = onloadfunction;// set onload funciton
but never see google displayed!
This has been frustrating. Works perfectly fine in Firefox, but just dies in IE. The onload doesn't seem to want to work when the function is in the head script, but if I put all the script in the body, it loads slower. I've tried window.onload, but it doesn't seem to work well since my images need to be modified after it loads.
View 1 Replies View RelatedDoes onload always have to be in the <body> tag?
View 2 Replies View RelatedI have two things that need to upload in the body, but I'm not sure how to do this, I've tried adding it like this:
<body onload="load();" OnLoad="loadImages()">
but only the first one loads.
does anyone know how to make both load?
Supposedly there are two functions that should run when my page's window loads. One for my clock and one for my new ticker. I can locate the clock function on window.onload, but not the one for the marquee that would stop it from working. Code:
View 3 Replies View RelatedIs it possible to go to a section of a page when that pages loads? Ex:
<body onload="#idname">
I know that doesn't work, but I think it shows what I am trying to do.
I'm new to DOM and javascripting and have constructed a hide/show menu. I can't find a way to keep IE6 from revealing all the sub-lists onload. The code (inspired by PPK and Jeremy Keith's recent books) follows:
window.onload = function () {
var topnav = document.getElementById ("navmain");
var parent = document.getElementsByTagName("ul");
for (var i=0;i<parent.length;i++) {
if (parent[i].className != "section") continue;
parent[i].style.display = "none";
var header = parent[i].previousSibling;
if (header.nodeType != 1)
header = header.previousSibling;
header.relatedTag = parent[i];
header.onclick = openClose;
}
}
function openClose () {
var currentValue = this.relatedTag.style.display;
var newValue = (currentValue == "none") ? "block" : "none";
this.relatedTag.style.display = newValue;
}
Markup:
<div id="navmain" class="clearfix">
<ul><li><h4>Markets</h4>
<ul class="section">
<li><a href="/corporate/">Corporate</a></li>
<li><a href="/govt/">Govt/Agency</a></li>
<li><a href="/municipal/">Municipal</a></li>
<li><a href="/mbsabs/">MBS/ABS/CDO</a></li>
<li><a href="/funding/">Funding</a></li>
</ul>
</li></ul>
</div>
Hoping for some simple solution, but all advice is welcome.
why this combo works perfectly in IE and FF:
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
[Code]....
Quick one: Does onload fire after all the page has loaded, including images? If not, how do I trigger a function after everything is downloaded?
View 1 Replies View RelatedI'm trying to get a popup working on my site. I use headers and was wondering if there is a way to put the onload outside of the BODY tag? My header has the BODY tag in it. I only want the popup to come up on one page and not all the pages that use my header.
View 2 Replies View RelatedI have created a page that takes a person to another page automatically:
<body
However, the script waits for the entire page to load before actually taking the person to the other page. What I need to do is to have a script that takes the visitor to the target page as soon as the page appears (without waiting for ads to load completely). How can this be done?