473,606 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JavaS cript"> document.sendqu ickmsg.qmsg.foc us(); </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 1964
"Daniel Kaplan" <No****@NoSpam. com> wrote in message
news:11******** *******@nntp.ac ecape.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("doc ument.getElemen tById('test').f ocus();", 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
11261
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 which are fixed. Then a div tag inside which there is a table which is used for scrolling the data.When i select a radio i'm submitting the form.The problem is here i'm able to set focus to the radio button, but i'm unable to maintain the...
6
2489
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 name="q" in different forms on the page. <A onClick="changeFocus('basicsearch')" HREF="#basic">basic site search</A> <A onClick="changeFocus('advancedsearch')"
2
1614
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 searched words are inside <a href> tags, the links are lost after putting my anchors. For example: <a class="Programa" href="#" OnClick="window.open('/something.tif');"
1
2026
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 searched words are inside <a href> tags, the links are lost after putting my anchors. For example: <a class="Programa" href="#" OnClick="window.open('/something.tif');"
9
9495
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, 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.getElementById(element).focus() ? I'm trying to get the focus to a specific paragraph, so the page scrolls to it on loading,...
3
6073
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 above where the error field is then the page will scroll so that the error field is at the very top of the window. If you happened to have the page scrolled below where the error field is then the page will scroll so that the error field is at...
0
1761
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 happened always whenever DataSource is set, only called sometimes, in a series of setting DataSource, I could get this setting focus only one time . Can anybody help me how to stop this one. system.windows.forms.dll!
2
7398
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 activate the MDI is something like the following: frmTest frm = new frmTest(); frm.MdiParent = this; frm.Show();
1
1349
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 basic code: var anchors = document.getElementsByTagName("a"); for (var i = 0; i < anchors.length; i++)
0
7981
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8462
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 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...
0
6803
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, 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...
1
5994
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3952
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...
0
4011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2458
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
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1315
bsmnconsultancy
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...

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.