473,657 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2921
wrote on 18 mrt 2006 in comp.lang.javas cript:
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:aler t((document.doc umentElement||d ocument.body).i nnerHTML)

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="javas cript" type="text/javascript">
objTreeMenu_1 = new TreeMenu("image s", "objTreeMenu_1" , "_self",
"treeMenuDefaul t", true, false);
newNode = objTreeMenu_1.a ddItem(new TreeNode('First level<a
href=ct></a>', 'folder.gif', null, true, true, '', '',
'folder-expanded.gif')) ;
newNode.setEven t('onexpand', 'alert(\'Expand ed\')');
newNode_1 = newNode.addItem (new TreeNode('Secon d level',
'folder.gif', 'test.php', false, true, '', '', 'folder-expanded.gif')) ;
newNode_1_1 = newNode_1.addIt em(new TreeNode('Third level',
'folder.gif', 'test.php', false, true, '', '', 'folder-expanded.gif')) ;

.......

objTreeMenu_1.d rawMenu();
objTreeMenu_1.w riteOutput();
objTreeMenu_1.r esetBranches();

</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.l ocation("ct")) doesn't work.

Mar 18 '06 #3
VK

da********@gmai l.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.l ocation("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.ht ml" to "siteMap.html#c t"

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.javas cript:
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.c om, 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/googlegroupsrep ly/>
Here's my code, the javascript is generated
from the PHP module TreeMenu.php:

======
<script language="javas cript" type="text/javascript">
language="javas cript" is no longer needed, leave it out!
objTreeMenu_1 = new TreeMenu("image s", "objTreeMenu_1" , "_self",
"treeMenuDefaul t", true, false);
newNode = objTreeMenu_1.a ddItem(new TreeNode('First level<a
href=ct></a>', 'folder.gif', null, true, true, '', '',
'folder-expanded.gif')) ;
newNode.setEven t('onexpand', 'alert(\'Expand ed\')');
newNode_1 = newNode.addItem (new TreeNode('Secon d level',
'folder.gif', 'test.php', false, true, '', '', 'folder-expanded.gif')) ;
newNode_1_1 = newNode_1.addIt em(new TreeNode('Third level',
'folder.gif', 'test.php', false, true, '', '', 'folder-expanded.gif')) ;

.......

objTreeMenu_1.d rawMenu();
objTreeMenu_1.w riteOutput();
objTreeMenu_1.r esetBranches();
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.l ocation("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********@gmai l.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.l ocation("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
2710
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
3613
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 Morris -- my IE6 favorites for import into Netscape/Internet Explorer
5
11037
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 similar. I'm succeeding in doing this by using Writer.Write to emit my HTML, at least as far as getting it to work. However, depending on where I put MyBase.Render(Writer), I get my HTML either before the header or after the end of the body of...
1
1643
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 3 external js files to show a js menu in the header page. Nothing I've tried works and I don't want to monkey with the PERL file. If there is a way to generate the menu, I'd sure appreciate the code because I'm only slightly better at javascript...
2
1347
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 works in Mozilla. In the generated code I'm linking to a Javascript file "artscripts.js". When I remove this line of code the script works fine (except of course I can't call the javascript functions contained in the linked file). The first...
3
15100
by: Chandra | last post by:
How do I programmatically (javascript) check if link is valid in html?
2
1881
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 according to the input in the textbox and the web page is displayed to the user. Now on clicking Save also, with the same input to the textbox, the same set of data will be fetched from the database, but in this case I do not want the web page...
6
1333
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 this usings commands such as: <SCRIPT src="folder/functions.js" type=text/javascript></SCRIPT> However, when I try this it does not work. Can anyone explain what I need to do to make this work OR point me in the direction of a suitable tutorial...
7
3204
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. Onmouseover javascript read area names and send it to javascript generated page. On generated page, area name (from first page) need to be query variable (depending of them show data from database). If i put string instead of variable,everything works fine,...
0
8319
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
8837
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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...
1
8512
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4171
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
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
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
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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.