473,735 Members | 1,919 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 2931
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
2716
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
3624
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
11041
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
1647
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
1351
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
15106
by: Chandra | last post by:
How do I programmatically (javascript) check if link is valid in html?
2
1887
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
1337
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
3217
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
9466
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
9330
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
9202
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8202
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...
0
6050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3278
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
2741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2191
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.