SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : Dynamic HTML :

Previous DiscussionNext Discussion
 How can I open a div from a URL

I have a page that has div's that are hidden until they are opened with a javascript onClick. Is it possible to have a link to this page that will have one of the div already opened. the code below is the textlink that opens the div on the page, and the div it is opening. The div has alot of text in it so I removed it. I want to be able to have another page that will link to this one, but with the div below already opened.

<td nowrap="true"><a href="javascript:;" onClick="return expandcontent('sc2_2', this)">Travel Insurance</a></td>



<div id="sc2_2" style="display:none;">

</div>

Started By mwenn1 on Apr 27, 2006 at 2:49:25 PM

7 Response(s) | Reply

Earlier Replies | Replies 2 to 7 of 7 | Later Replies
Goto Page: 1
bod1467 on Apr 28, 2006 at 2:58:01 AM (# 2)

Pass a URL parameter and have your JavaScript check this onload?


raphpell on Apr 28, 2006 at 5:07:53 AM (# 3)
This message has been edited.

I dont understand the thing you want to create but we can display a DIV with the over event of links.

<STYLE>
a.popup:visited       { color: #000; text-decoration:none; border-bottom: 0em solid #000; }
a.popup                 { color: #000; text-decoration:none; border-bottom: 0em solid #000; position: relative; left:0px; font-weight: bold; }
a.popup SPAN       { display: none; }
a.popup:hover        { color: #000; cursor: default; border-bottom: 0.2em solid lime; }
a.popup:hover .popbox { background: red; display: block; position: absolute; z-index: 10000; top: 0em; left: 0em;  padding: 1.5em; }
</STYLE>


<a class="popup" href="#ceci" name="ceci">
 <SPAN class="popbox">Some text</SPAN>
 Label
</a> 

It works without JavaScript !


Akwok on Apr 29, 2006 at 6:07:13 AM (# 4)
This message has been edited.

Dear raphpell, I think Mr. / Ms. mwenn1 wanted to ask: when opening a "new page", a hidden div, which could be displayed be click an <a> at that "new page", could be opened.

I post this message is only to say thank you to raphpell. You've shown me how something can be acheived in different ways. And also you've lead me a way to a solution, which is displaying a <div> when needed, and that <div> will hide itself automatically.

Perviously, I used javascript to acheive it. And it works well. However, because of my low level programming skill in javascript, I can't make it to display in the way I want, which is the same as your hints. Meanwhile, I have the ambitous to acheive a little bit more.

That <div> consists of a <table> (after some learning in CSS, I know it is better to apply CSS positioning instead of <table>, but....:p), I tried to modify the javascript to acheive while clicking on <popup> or anything within <popup>, the original effect will be activated. I tried to access the lastchild node's property. But I don't know how to determine whether the lastchild node is a <table>.

Can you lead me a way to access this?

Thanks in advance.

~


raphpell on Apr 29, 2006 at 7:31:52 AM (# 5)
This message has been edited.

Event bubble up. So

  • Add a "onclick" event  to your popup.
  • Get the .target or .srcElement attributes of the event.
  • Access PopUp Node Elements.
  • Test the .nodeName attributes for each Node.
  • Execute your "original effect" function.

... no comment ...

Don't forget to delete all white space between all HTML TAG : these are TEXT NODE for all browser who respect W3C DOM recommendation.


RSugelSr on Apr 29, 2006 at 7:43:40 AM (# 6)

mwenn1,

If you want to display the same div every time this page is loaded from the link, call the same function that you call from the onclick event in the body onload event e.g.; <body onload="expandcontent('sc2_2', this)">. If you want the div that displays to be link dependent (what displays is dependent on which link is clicked), you can pass a parameter (url.htm?div=divToOpen), grab that by parsing the url, assign it to a variable and call it with <body onload="expandcontent(varDivToOpen)">.

Your expandcontent function may have to be modified (I'm not sure what passing in this does) since you won't have a clicked object.


raphpell on Apr 29, 2006 at 7:52:53 AM (# 7)
This message has been edited.

Try to simplify your code. All mustn't be reusable but if it can be readable...


Earlier Replies | Replies 2 to 7 of 7 | Later Replies
Goto Page: 1

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.