469,343 Members | 5,350 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

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 2622
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by quikquic | last post: by
1 post views Thread by Neil Morris | last post: by
1 post views Thread by Dave | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.