473,395 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Setting focus AND anchors

Hello All,

I have a Perl script that creates my HTML, which has a form, and then I set
focus to a specific part of the form with:

...my form and input fields here....
</form>
<script language="JavaScript"> document.sendquickmsg.qmsg.focus(); </script>

But just now I added an anchor in the link, so that my browser scrolls right
to the edit field. So my script is called with the achor
(http:.../myscript.pl?id=123#myanchor)

What I have found is that my Javascript set focus call no longer works if I
call the anchor. But still works if I don't.

Does one cancel out the other? Is there a work around?

Thanks ahead,

Daniel
Feb 19 '06 #1
1 1960
"Daniel Kaplan" <No****@NoSpam.com> wrote in message
news:11***************@nntp.acecape.com...
(http:.../myscript.pl?id=123#myanchor)

What I have found is that my Javascript set focus call no longer works if
I call the anchor. But still works if I don't.

Does one cancel out the other? Is there a work around?


In case anyone ever comes across this as well, here is the solution I was
given that seems to work best:

Ported the Javascript code for this over to one of my JS files in a
function.

Called that function with onLoad event for that specific page via the HEAD
section of that page.

And the focus is done withing a setTimeout method (to give the page time to
scroll I guess)
.... setTimeout("document.getElementById('test').focus( );", 100);

Because, as the person who discovered the solution said: "Seems that the
goto anchor happens after the page onload method is called, tedious."

So the bottom line is that I get my scroll (anchor) and setfocus too.
Feb 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Muralidhar | last post by:
Hi, I'm having a jsp page which is having a table and a div tag.The heading such as a radio button,Name , Age etc. are fixed.Only the data under it is scrolling. So i've set one table for header...
6
by: Brian | last post by:
I'm trying unsuccessfully to use a variable in a script that changes focus. Depending on which link a user follows (navigates via keyboard or clicks), I'd like to change the focus to an input...
2
by: mlv2312 | last post by:
Hi, I have experienced problems when dealing with nested anchors. I implemented some code to perform highlighting and specific anchors are used for the searched words. The problem is when the...
1
by: mlv2312 | last post by:
Hi, I have experienced problems when dealing with nested anchors. I implemented some code to perform highlighting and specific anchors are used for the searched words. The problem is when the...
9
by: s_m_b | last post by:
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,...
3
by: Simon Wigzell | last post by:
When I validate a form on submission I use the javascript focus function to scroll the page to the location of the form error e.g. document...focus(); If you happened to have the page scrolled...
0
by: Shravan | last post by:
Hi, I have a Windows Forms Custom DataGrid, which is put in a usercontrol, which on setting DataSource is setting focus to grid. The call stack for setting the focus is as follows. This is not...
2
by: Mystery Man | last post by:
We have an MDI application that is not setting always setting focus to the newly corrected MDI. It is creating the form and it is the topmost but it does not have focus. The code we are using to...
1
by: Pim Sohful | last post by:
Hi, I have a website full of external links. On the site I have a checkbox where users can indicate that they want to have the link opened in a new window or in the same window. It is rather...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.