473,395 Members | 1,502 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.

jump to link in page in javascript generated HTML

Hi,

(--1--)

I'm trying to find a way to jump to a link (<a href="ref"></a>) in a
page
that is generated with javascript.

The source view of the page only shows the javascript methods.
The HTML is *not* visible in the source view.

Passing the "#ref" on the URL doesn't work.
Changing window.location to "ref" neither.

Is this actually possible?

(--2--)

The scrollTo(x,y) function with javascript generated HTML seems
also problematic with IE, not with Mozilla. Well I'm having probs
with scrollTo(x,y) on IE in all cases, even static HTML...

Thanks!

Mar 18 '06 #1
6 2887
wrote on 18 mrt 2006 in comp.lang.javascript:
Hi,

(--1--)

I'm trying to find a way to jump to a link (<a href="ref"></a>) in a
page
that is generated with javascript.
Do you mean:

<a name="ref"></a>

?
The source view of the page only shows the javascript methods.
The HTML is *not* visible in the source view.
Not relevant, you probably can see the code with this:

javascript:alert((document.documentElement||docume nt.body).innerHTML)

Passing the "#ref" on the URL doesn't work.
Changing window.location to "ref" neither.

Is this actually possible?
What is "passing to"? Show us your code.

(--2--)

The scrollTo(x,y) function with javascript generated HTML seems
also problematic with IE, not with Mozilla. Well I'm having probs
with scrollTo(x,y) on IE in all cases, even static HTML...


Use body-onload, the page has to be ready first
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 18 '06 #2
Thanks for the reply. Here's my code, the javascript is generated
from the PHP module TreeMenu.php:

======
<script language="javascript" type="text/javascript">
objTreeMenu_1 = new TreeMenu("images", "objTreeMenu_1", "_self",
"treeMenuDefault", true, false);
newNode = objTreeMenu_1.addItem(new TreeNode('First level<a
href=ct></a>', 'folder.gif', null, true, true, '', '',
'folder-expanded.gif'));
newNode.setEvent('onexpand', 'alert(\'Expanded\')');
newNode_1 = newNode.addItem(new TreeNode('Second level',
'folder.gif', 'test.php', false, true, '', '', 'folder-expanded.gif'));
newNode_1_1 = newNode_1.addItem(new TreeNode('Third level',
'folder.gif', 'test.php', false, true, '', '', 'folder-expanded.gif'));

.......

objTreeMenu_1.drawMenu();
objTreeMenu_1.writeOutput();
objTreeMenu_1.resetBranches();

</script>

=========
somewhere in the code you see <a href="ct"></a>.
I'd like to jump to that when the page is shown in the browser.
The page is printed as a treemenu. the drawmenu() function
corresponds to document.write(str).

The onload(window.location("ct")) doesn't work.

Mar 18 '06 #3
VK

da********@gmail.com wrote:
somewhere in the code you see <a href="ct"></a>.
I'd like to jump to that when the page is shown in the browser.
The page is printed as a treemenu. the drawmenu() function
corresponds to document.write(str).

The onload(window.location("ct")) doesn't work.


You are confused about anchors and links.
<a href="ct"></a> is not an anchor, it's a link. You cannot navigate to
it by HTML means. In order to make it both link and anchor, you need to
give it a name:

<a href="somePage.html" name="ct">Link and Anchor</a>

Now you can refer to this place on your page as ...href="#ct"...

And if your page is served anyway by PHP, it is easier to make
server-side redirect then, so the url would be changed from say
"siteMap.html" to "siteMap.html#ct"

This way the "jump" will be done even with JavaScript disabled.

Mar 18 '06 #4
Thanks a lot. With this little bit of elementary knowledge you ended a
stretch of 3 day frustration.

Mar 18 '06 #5
wrote on 18 mrt 2006 in comp.lang.javascript:
Thanks for the reply.
Please quote what you are replying to.
This is NOT email!
If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the
article headers. <http://www.safalra.com/special/googlegroupsreply/>
Here's my code, the javascript is generated
from the PHP module TreeMenu.php:

======
<script language="javascript" type="text/javascript">
language="javascript" is no longer needed, leave it out!
objTreeMenu_1 = new TreeMenu("images", "objTreeMenu_1", "_self",
"treeMenuDefault", true, false);
newNode = objTreeMenu_1.addItem(new TreeNode('First level<a
href=ct></a>', 'folder.gif', null, true, true, '', '',
'folder-expanded.gif'));
newNode.setEvent('onexpand', 'alert(\'Expanded\')');
newNode_1 = newNode.addItem(new TreeNode('Second level',
'folder.gif', 'test.php', false, true, '', '', 'folder-expanded.gif'));
newNode_1_1 = newNode_1.addItem(new TreeNode('Third level',
'folder.gif', 'test.php', false, true, '', '', 'folder-expanded.gif'));

.......

objTreeMenu_1.drawMenu();
objTreeMenu_1.writeOutput();
objTreeMenu_1.resetBranches();
This is all based on a library you do not show, so we cannot comment on
that.

</script>

=========
somewhere in the code you see <a href="ct"></a>.
I'd like to jump to that when the page is shown in the browser.
You cannot, unless you give it a name, as I told you before.
The page is printed as a treemenu. the drawmenu() function
corresponds to document.write(str).

The onload(window.location("ct")) doesn't work.


elementary, my dear unnamed.

Please try to learn some javascript. This NG is not a helpdesk for
correcting machine generated script. That is like asking a translator for
corrections to a bad machine translation.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 18 '06 #6
VK wrote:
da********@gmail.com wrote:
somewhere in the code you see <a href="ct"></a>.
I'd like to jump to that when the page is shown in the browser.
The page is printed as a treemenu. the drawmenu() function
corresponds to document.write(str).

The onload(window.location("ct")) doesn't work.


You are confused about anchors and links.


Nonsense. Will you ever get informed properly before you post advice?

<URL:http://www.w3.org/TR/html4/struct/links.html>
PointedEars
Mar 20 '06 #7

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

Similar topics

9
by: quikquic | last post by:
Suppose I download a html file with javascript in it, for example, <html> <body> <script language="JavaScript"> document.write("Hello"); </script> </body> </html>
1
by: Neil Morris | last post by:
Hi I was wondering if there was a way to view the html code that javascript produced since viewing the source code shows the javascript if statements for netcrape and IE etc. thanks Neil...
5
by: Rick Spiewak | last post by:
I need to generate a "buy" button as part of an ASP.NET page - this consists of a small HTML form with hidden fields, conforming to the requirements of a merchant credit card processor. PayPal is...
1
by: Dave | last post by:
I have "header.html" used by PERL to construct an entire page. Unfortunately, this header page contains no head or body tags; the script generates them. So I am at a loss as to how I can reference...
2
by: Design2d | last post by:
Hi, if anyone can help with this I'd be very grateful: I'm generating an html popup window with Javascript. When the popup appears in Explorer 6.0 it is empty and crashes the browser, though it...
3
by: Chandra | last post by:
How do I programmatically (javascript) check if link is valid in html?
2
by: ppuniversal | last post by:
Hi All, My question is as follows: I have a text box and two links.Let the two links be - Show and Save . On clicking the Show , a web page is generated by fetching some data from database...
6
by: Blackmore | last post by:
I'd like to screate a link to my javascript functions, such that they do not appear in the page source code and users cannot tamper with them. I've noticed that other websites appear to be able to...
7
by: Arsale | last post by:
I am trying to pass a javascript variable to php on javascript generated page, but on the new page I got only "Array". Where did I go wrong? On first page, i've got image map with areas....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.