469,612 Members | 1,657 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Access <div> element from another template.using JS

Hi,
I am developing a website . The home page contains 10 different html templates.
What I need to do is that i want to access a div tag from a template which is defined in another html template. I tried

document.getElementById('d').innerHTML="some text";

but it is showing null.

Is there any way to define <div> as global so it is accessible from any other html template.

Kindly help me on this.
Oct 10 '08 #1
3 2687
acoder
16,027 Expert Mod 8TB
Are you using iframes or frames to include the HTML pages?

If so, you need to access the (i)frame first and then access the elements within.
Oct 10 '08 #2
Are you using iframes or frames to include the HTML pages?

If so, you need to access the (i)frame first and then access the elements within.

I am using neither of them. My final html page consists of different templates(html pages). I am using symfony framweork for development. The html code is written in symfony templates & then the templates are included into a final template which displays an html page.
Oct 10 '08 #3
gits
5,390 Expert Mod 4TB
the javascript code runs when the page is rendered at the client - so to be sure that the div with the id 'd' (the one you use) is available for the dom-method then you should ensure that the execution of the javascript code is triggered when the page is fully loaded and the dom is ready to use - you might use the documents onload event for this purpose ...

kind regards
Oct 10 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

14 posts views Thread by Simon Wigzell | last post: by
4 posts views Thread by joe | last post: by
28 posts views Thread by Kent Feiler | last post: by
5 posts views Thread by chakradhari.ashish | last post: by
10 posts views Thread by Summercoolness | last post: by
2 posts views Thread by paul | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.