I'm trying to get an <a> element to gain the focus onload, but only get
back 'has no properties'.
Reading through this ng, its clear that unless the element is within a
form, this doesn't happen, but according to the w3 TR on html 4.01, the a
element can take onFocus commands, which to me means you can do
document.getEle mentById(elemen t).focus() ?
I'm trying to get the focus to a specific paragraph, so the page scrolls to
it on loading, but as the page in question is dynamic, i can't feed the #
van the URL 9 9511
s_m_b wrote: I'm trying to get an <a> element to gain the focus onload, but only get back 'has no properties'. Reading through this ng, its clear that unless the element is within a form, this doesn't happen, but according to the w3 TR on html 4.01, the a element can take onFocus commands, which to me means you can do document.getEle mentById(elemen t).focus() ?
<a> elements have onfocus intrinsic events, which means you can make
things happen when they gain focus, usually by tabbing to or clicking
on them. It does not mean the element has a focus() method. I'm trying to get the focus to a specific paragraph, so the page scrolls to it on loading, but as the page in question is dynamic, i can't feed the # van the URL
That is what anchors are for. Giving the <a> focus will not
necessarily scroll the page to it, but using it as an anchor will if
there is sufficient depth in the page.
<URL:http://www.w3.org/TR/html401/struct/links.html#h-12.1>
--
Rob
RobG <rg***@iinet.ne t.auau> wrote in
news:42******** *************** @per-qv1-newsreader-01.iinet.net.au : s_m_b wrote: I'm trying to get an <a> element to gain the focus onload, but only get back 'has no properties'. Reading through this ng, its clear that unless the element is within a form, this doesn't happen, but according to the w3 TR on html 4.01, the a element can take onFocus commands, which to me means you can do document.getEle mentById(elemen t).focus() ? <a> elements have onfocus intrinsic events, which means you can make things happen when they gain focus, usually by tabbing to or clicking on them. It does not mean the element has a focus() method.
ah - that explains it. I'm trying to get the focus to a specific paragraph, so the page scrolls to it on loading, but as the page in question is dynamic, i can't feed the # van the URL
That is what anchors are for. Giving the <a> focus will not necessarily scroll the page to it, but using it as an anchor will if there is sufficient depth in the page.
<URL:http://www.w3.org/TR/html401/struct/links.html#h-12.1>
yes, that I know, but if you add '?x=y' into the URL it doesn't work any
more. You either get the contents of the GET ignored or the anchor
reference is.
I'm having a similar situation with normal text links. For example,
after closing an iframe or hiding a division I want focus to go to a
certain text link. I tried:
document.links[2].focus;
to target the 3rd link on the page after the closing or hide, and it
doesn't work. Is this possible ?
Later, Art.
In my previous post I forgot to point out that the:
document.links[2].focus;
is not part of a function. It's a stand alone statement within the
script tags. Might that be the problem ?
s_m_b wrote: RobG <rg***@iinet.ne t.auau> wrote in news:42******** *************** @per-qv1-newsreader-01.iinet.net.au :
s_m_b wrote:
I'm trying to get an <a> element to gain the focus onload, but only get back 'has no properties'. Reading through this ng, its clear that unless the element is within a form, this doesn't happen, but according to the w3 TR on html 4.01, the a element can take onFocus commands, which to me means you can do document.get ElementById(ele ment).focus() ?
<a> elements have onfocus intrinsic events, which means you can make things happen when they gain focus, usually by tabbing to or clicking on them. It does not mean the element has a focus() method.
ah - that explains it.
I'm trying to get the focus to a specific paragraph, so the page scrolls to it on loading, but as the page in question is dynamic, i can't feed the # van the URL
That is what anchors are for. Giving the <a> focus will not necessarily scroll the page to it, but using it as an anchor will if there is sufficient depth in the page.
<URL:http://www.w3.org/TR/html401/struct/links.html#h-12.1>
yes, that I know, but if you add '?x=y' into the URL it doesn't work any more. You either get the contents of the GET ignored or the anchor reference is.
I think you need to explain a bit more about what you are trying to
do - do you have bit of code showing what you are up to?
--
Rob
Art X wrote: I'm having a similar situation with normal text links. For example, after closing an iframe or hiding a division I want focus to go to a certain text link. I tried:
document.links[2].focus;
to target the 3rd link on the page after the closing or hide, and it doesn't work. Is this possible ?
Later, Art.
Give the a element a name, that makes it an anchor. Fire some event
and set the page location to <currentURL> + '#' + <anchorName>.
That will navigate to the link and put it in focus:
<a href="#freddy"> freddy</a>
<br><br><br><br ><br><br><br><b r><br><br><br>< br><br><br><br>
<br><br><br><br ><br><br><br><b r><br><br><br>< br><br><br><br>
<a name="freddy" href="http://www.apple.com" onfocus="
alert('Hey, ' + this.name + ' got focus');">Apple </a>
--
Rob
Art X wrote: In my previous post I forgot to point out that the:
document.links[2].focus;
is not part of a function. It's a stand alone statement within the script tags. Might that be the problem ?
I ignored it. If you were trying to call the focus method, then:
document.links[2].focus();
will do the trick, but using an anchor will work without JavaScript.
Probably should test the method before trying to use it:
if (document.links[2].focus) document.links[2].focus();
--
Rob
Thanks Rob,
I'll try the anchor.
Later, Art.
RobG <rg***@iinet.ne t.auau> wrote in
news:42******** *************** @per-qv1-newsreader-01.iinet.net.au : s_m_b wrote: RobG <rg***@iinet.ne t.auau> wrote in news:42******** *************** @per-qv1-newsreader-01.iinet.net.au :
s_m_b wrote:
I'm trying to get an <a> element to gain the focus onload, but only get back 'has no properties'. Reading through this ng, its clear that unless the element is within a form, this doesn't happen, but according to the w3 TR on html 4.01, the a element can take onFocus commands, which to me means you can do document.getEle mentById(elemen t).focus() ?
<a> elements have onfocus intrinsic events, which means you can make things happen when they gain focus, usually by tabbing to or clicking on them. It does not mean the element has a focus() method.
ah - that explains it.
I'm trying to get the focus to a specific paragraph, so the page scrolls to it on loading, but as the page in question is dynamic, i can't feed the # van the URL
That is what anchors are for. Giving the <a> focus will not necessarily scroll the page to it, but using it as an anchor will if there is sufficient depth in the page.
<URL:http://www.w3.org/TR/html401/struct/links.html#h-12.1>
yes, that I know, but if you add '?x=y' into the URL it doesn't work any more. You either get the contents of the GET ignored or the anchor reference is.
I think you need to explain a bit more about what you are trying to do - do you have bit of code showing what you are up to?
ah............. .
I've just been through the code in a little more depth to check it, and
found the problem - the anchor I was sending is missing on the target
document. Another anchor that I've just tried, does exist and works.
I'll have to find where this duff one comes from now [blush] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mica Cooper |
last post by:
Trying to set the focus to an element of input type on loading the page.
This is the code I used but it doesn't work. Any suggestions? (IE 6,
Windows)
<SCRIPT language=JavaScript>
funcion setFocus() {
document.formname.fieldname.onfocus();
}
</SCRIPT>
|
by: Csaba |
last post by:
I'd like to have the cursor in the login form's username input text
field when users load the login page.
It works fine with the following implementation:
<body onload="document.login.username.focus();">
<form name="login" method="post" action="<?=$PHP_SELF?>">
<input type="text" name="username" onLoad="self.focus();">
The problem is that the input field's name cannot be simly "username",
because it posts an element of an array,...
|
by: lawrence |
last post by:
If I'm pretty sure there is just one form on the page, can i do this?
var myForm = document.forms;
If I'm not sure about the form, is it safer to do this?
if (document.forms) {
var myForm = document.forms;
// more code here........
}
|
by: Peter Wright |
last post by:
Hi all.
Hopefully this should demonstrate the problem I'm having:
http://flooble.net/~pete/focus-problem-demo/
(I'm testing it in Mozilla only, but I'm not sure if it's actually a
Mozilla-only problem)
I'm capturing the focus and blur events for the document, updating a
|
by: Praveen |
last post by:
In IE a table element will receive focus when you either tab into it or
when you click anywhere within the table. Mainly it fires the onfocus
event.
This doesn't happen in Mozilla (Firefox and Netscape).
Is there any setting or anyother way to force the table element to fire
the onfocus and onblur events?
Thanks
| |
by: Vinod. |
last post by:
Hi all,
I have added browser control to a windows form. I am loading pages
having multiple frames. I have noticed that the focus in a text is not
maintained when the application is deactivated. I fixed this issue by
finding the active element in dom and then setting its focus. If the
active element is a frameelement then I get the document of the
frameelement and then get the activeelement of that document and set
the focus. This works...
|
by: bagya |
last post by:
please help me out
the following is the small code i have
<html>
<head>
<script type="text/javascript">
function validate()
{
if (document.abc.region.value==0)
|
by: dlite922 |
last post by:
Before traversing my code, here's what my goal is and what this function does:
I have a table of fields that dynamically grows as the user enters information. A minimum of 3 rows must always exist. (read the psedo code and comment if you need to know what it does)
disregard the debugging , commented alerts.
What i'm trying to do is without passing the ID or field that called this function, set the focus to the next element. what's...
|
by: Claus Mygind |
last post by:
I am creating an element dynamically as I load it on the screen. When it was hard coded on the page I had no problem executing the following two lines.
document.getElementById("SEARCH").select();
document.getElementById("SEARCH").focus();
Now I create the element the following way (see below) in my js function followed by the two lines above. I get no error message, but the input field has not received focus.
td.innerHTML...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |