Toggle Content Script: Content Shown When JavaScript Is Off

Jul 21, 2007

I use a small piece of JS code to make different elements on the page show/hide when clicking a link, based on id:

function toggle( targetId ){
if (document.getElementById){
target = document.getElementById( targetId );
if (target.style.display == "none"){
target.style.display = "";
} else {
target.style.display = "none";
}
}
}
Then HTML looks like this:
<a href="#" onClick="toggle('news'); return false;">Show/hide news</a>
<div id="news" style="display:none">BlahBlahBlah</div>

This works. Initially the element is hidden (with style="display:none" property of the element), and the script gets its id and changes its display property to "block" when clicking on a link.

But when Javascript in a browser is turned off, the elements to show are all hidden, and there's no way to see the content of the element.

My question: is there a way to hide toggled elements on page load with JS, so that when it's turned off the hidden content is shown?

View 5 Replies


ADVERTISEMENT

Toggle Div, Loading Content Externally On Toggle

Sep 1, 2011

here is my scenario:

I have a link and a div on a webpage. With the link I want to toggle the content (HTML) of the div. On toggle, I want to load the content from a PHP-file and I want it to load on the toggle, not when the webpage originally loaded (to reduce loading time on the webpage itself).

The file that is loaded on toggle doesn't have to be PHP, but it would help a lot.

View 1 Replies View Related

JQuery :: Toggle And Driven Content?

Dec 6, 2010

jQuery and based on a tutorial for a toggle function I want to do a toggle with a dynamic content for the collapsed DIVs. My code looks like that:

$(document).ready(function(){
//Hide (Collapse) the toggle containers on load
$(".toggle_container").hide();

[code]....

View 4 Replies View Related

JQuery :: Ajax Menu Content Will Not Toggle?

Oct 29, 2009

I have a menu that grabs content via ajax and json. This menu has 3 levels. I can click on the first level and it loads fine. This is the .cat class that then toggles. However when I click on the 2nd level link, the .ahref class it does not fire.

[Code]...

View 2 Replies View Related

Jquery :: Toggle Content Using Horizontal Menu Bar

Nov 11, 2011

I've been trying to build my website so that the user first starts at the home page. Whenever the user clicks on the horizontal menu/navigation bar, the new content would push the home page content down. Clicking on another menu/navigation item would also push everything down and display the new content above it. I've been researching and figured i'd have to use jquery toggle. I've looked at multiple guides, and the one at

[URL]

is like what i'm trying to do. However, I can't figure out how to toggle from a horizontal navigation/menu bar instead of using HEADERS like in the example link. I don't want to toggle content with the clickable toggle button stacked vertically. (Example: Toggle button --> Content --->Toggle Button----> Content)

View 4 Replies View Related

Spacegallery Hyperlink - Toggle Content Relating To The Particular Image

Sep 15, 2009

What I require seems straightforward, for each image in my gallery I would like to have a unique URL, so if there are 5 images then 5 different URL's thus enabling me to toggle content relating to the particular image, the code I believe I need to change is as follows;

[Code].....

View 3 Replies View Related

Change Width Of Website Content With Toggle Option?

Jan 30, 2010

I was wondering if anyone knows how you would create a link when clicked will change the width of the content.

I have a feeling this will use jQuery?

E.g.

A link saying 'expand' will change the width of the body to 1000px and change the link to 'contract'.

When the link 'contract' is clicked it will change the width back to 800px and change the link to 'expand'

View 3 Replies View Related

JQuery :: Toggle Show/hide Div - Overlapping Content?

Aug 27, 2010

I have the following show/hide div function made with jQuery:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

[Code].....

It toggles perfectly, but I would like to make to which appears to overlap the underlaying content div below. Right now it just pushes down the content div when sliding out.

View 2 Replies View Related

JQuery :: Use A Toggle To Hide And Show Some Content - Isnt Working ?

Jul 6, 2009

I want to use a toggle to hide and show some content but it isnt working

html code:

JS code:

But this code dont works correct, notiv that i want to use more then one box.

View 5 Replies View Related

Toggle Content - Included Block Level Stuff To Be Hidden

May 11, 2011

I'm looking for some javascript that'll toggle hidden content. As I'm not experienced in this, I want something which is cross-browser reliable - and I'm having trouble finding something suitable. Jquery has been suggested as an option... and I found something which appeared to do the job, apart from not validating as it uses a span to include the toggled content - which is a problem as I need to included block level stuff to be hidden. Also, it came as two buttons - show and hide - and I'd prefer a single button, or preferably a normal html link.

View 6 Replies View Related

JQuery :: Toggle Function Not Working - No Error Shown

May 2, 2010

Here is my code:
HTML: [URL]
Javascript: [URL]
and CSS: [URL]
And the second toggle isn't work !!! In Firebug, I do not get error!

View 1 Replies View Related

JQuery :: Featured Content Slider Using UI Not Functioning Within DHTML Tab Menu Content

Dec 20, 2010

1) Script Title: Ajax Tabs Content Script (v 2.2) and Featured Content Slider Using jQuery UI

2) Script URL (on DD): [URL]

3) Script URL of Featured Content Slider Using jQuery UI [URL]

4) Script URL of my implementation of both script. [URL]

5) Problem: I've integrated the featured content slider in one of the default content section of the tab menu as you can see on the link on point 4. The slider is working perfectly when until i click on other tab menu and then back tab menu 1. The slider seize to work no more and worst the other featured content slides are appearing below the first one.

View 6 Replies View Related

JQuery :: SlideUp Div Replace - Loads The Content Specified Into A Single Div - Replacing The Content Depending On Which Function Is Called

Nov 22, 2010

I have previously developed two scripts, both of which work really well, however I want to amalgimate them together if possible? My first script loads the content specified into a single div, replacing the content depending on which function is called, it also displays a loading gif during a timeout of 2 seconds. Here is the page:

[Code]...

View 1 Replies View Related

Calculating Height Of Iframe Content After Inserting The Content?

Nov 10, 2010

I'm using JQuery to write content into an otherwise empty iframe like so:

Code:

$('#ifrmID').contents.find('html').html(htmlContent);

The content is coming from an Ajax request. The content gets used more than once on the page for other purposes which is why I don't simply change the iframe src--I have to do an ajax request regardless so I'm trying to avoid multiple calls.

After I load the content, I need modify the height of the iframe so it fits snuggly around the content.

Calculating the height isn't a problem with the exception that it's not always correct and I think it's because the calculation is happening before images have downloaded.

I don't seem to be able to rely on a `load` or `ready` event to delay the calculation. The load event is the only one that tiggers on a change of iframe content, but it doesn't see the new content.

Code:

$('iframe').each(function () {
$(this).load(function () {
alert($(this).contents().find('html').html());
});
});


This will output '<html><body></body></html>' even though I have successfully inserted different content.

Any suggestions on what I'm doing wrong, or if it's possible to do what I want reliably?

Note that a general JS solution will be appreciated as much as a JQuery one.

View 4 Replies View Related

Jquery :: Reveals The Hidden Content When 'pushes' The Content Above Or Below

Jul 20, 2010

Most Jquery I have seen 'pushes' the content above or below it up or down the page as it reveals the hidden content, the above example reveals the content over the top without pushing out any other content which is what I am looking for I have tried to take the code and everything works aside from those tabs!! I was hoping somebody has a link to another site that does the same effect

View 1 Replies View Related

Saving Data - User Can Toggle The Hidden ExportData To Be Shown On The Webpage

Sep 6, 2011

Im modifying some open source code and in this instance I would like to write some data to a file (possibly for the user to download). In this code the user can toggle the hidden exportData to be shown on the webpage. However, I would like to give the option of downloading/saving the data as a file (only the exportData which I believe is the document.getElementById("path")). I have tried various tricks found online, but have yet to produce the hoped for result.

Code:

View 1 Replies View Related

JavaScript Switch Content

May 27, 2006

I've been driving myself crazy the past couple hours and can't figure this out. Here is what I need to do:

Have a select box like this:

<select name="dropdown">
<option value="option1">option1</option>
<option value="option2">option2</option>
</select>

Then when one of those options is selected, the appropriate div tag is displayed:

<div id="option1">
Div 1 Text
</div>

<div id="option2">
Div 2 Text
</div>

This seems like it should be really simple to do, but I can't figure it out.

View 5 Replies View Related

Embedding Content Via Javascript

Aug 2, 2007

I am trying to embed content via javascript using the following code:

<script type="text/javascript" src="http://example.com/script.php"></script>

When I place the script.php in other servers it works fine (content can be viewed) except with one server, it doesn't return anything (just blank screen). What could be the possible problem, is it a hotlinking issue or something else?

View 8 Replies View Related

JQuery :: Replacing DIV Content With Other DIV Content From Same Page?

Mar 18, 2010

I have content in hidden (invisible) DIV elements on a page that I want to load into another DIV element on same page. I need to replace content currently in a DIV with that coming from another DIV. DIV ontent could be a P element or a P and IMG element.

View 4 Replies View Related

How Do I Hide Javascript Content From Googlebot?

Jul 28, 2007

I have a piece of code that I'd rather google's spider did not follow. Is
this possible please?

View 8 Replies View Related

Content Positioning W/ Small Javascript

Mar 25, 2007

i made this javascript using the new "screen.width" property, which would make it easy to center content in a webpage no matter what the screen resolution is. Here it goes:

<html>
<head>
<script type="text/javascript">
function pos_center() {
var content = document.getElementById("carrier")
var width = screen.width
var contentwidth = content.offsetWidth
value = parseFloat((width - contentwidth)/2)
content.style.marginLeft = value }
</script>
</head>
<body
<div class="body" id="carrier">
</div>
</body>
</html>

The "body onload" makes the page first load all the way to the left, and then after completely loading switches the content to the center, that is dynamically gross.
Now, instead of using the "body onload", is there any other way that i can make the content appear. Seeing that there is no "onbeforeload", there must be another way to solve this.

View 1 Replies View Related

Re-Write A Layer's Content With Javascript

Mar 26, 2003

This forum thread discusses the SitePoint article 'Re-Write a Layer's Content with Javascript' by Peter Todorov.

"How can you can replace the content of a Web page without additional requests to the server? The answer uses layers in JavaScript - Peter explains all."

View 17 Replies View Related

Mouseover Javascript To Change Content In A Table

May 4, 2005

I have a company that has a group of companies under it. I plan to add 4 company logos on one front page, and when the user mouses over one of the logos, I want a table below to change and show a description of that company.

The images that they will be mousing over will also need to change, and the table that will change should be able to carry a static message such as "Hover your mouse over the logos above to find out more".

View 7 Replies View Related

Dynamic Content Areas - JavaScript & Ajax???

Sep 29, 2005

I would like to build an HTML page that has four content areas. The first with 3 links that when clicked chage what is shown in the other 3 - and so changing the default content in these sections. The content for these sections will be contained in seperate HTML files sitting on the same server.

I understand this can be done without refreshing the page and believe JavaScript and Ajax is the best method to do this. Any advice?

View 2 Replies View Related

Dynamic Content Replacement Using Ajax/Javascript/PHP

Jun 26, 2007

I'm sure some wizard will tell me this is a classic example of "piece of cake"; in which case I bow and promise to listen In case I've struck granite rock, feel free to throw questions my way and I'll tell you if I've tried it or not.

I have a file, main.php (I know this is the JS-forum, bear with me). It outputs HTML and inline Javascript functions. When the user clicks on a graphical "tab", that tab is activated, and an ajax call is made to fetch.php with some specific parameters. Once the ajax request has completed, a given innerHTML container on the now active tab is filled with the stuff that fetch.php outputs.

So far so good.

The problem is that the stuff that fetch.php outputs is partial pure HTML and partial inline javascript. And this is where it gets tricky. If I declare an inline javascript function in the returned data, Firefox (and I suspect MSIE) refuses to understand that the function is there. It simply doesn't exist (!).

Using the Web Developer add-on for Firefox, there's an option to look at "Source code" and "Generated source code". The output from these two differ in that when I view the "Generated source code", I see the dynamically inserted javascript/HTML from fetch.php, whereas viewing "just" the source doesn't.

What did I do wrong? How do I get the browser to find/accept/activate the javascript code/functions that were inserted dynamically? I cannot put them in a .js file and include it, since they need to be dynamically created, and I cannot use eval() since that executes javascript "as is", in which a function will not be executed unless called.

View 5 Replies View Related

=> Scroll IFrame Content To Desired Position (JavaScript)

Jul 23, 2005

How can I scoll the content of an Ifram to a desire Position?

The function should be:
window.scrollTo(x,y)

BUT how do I have to use this function so that applies to the IFrame content.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved