Thursday, 18 August 2011

Using Placeholders to Position Divs

This is where I want the content.
This is a simple piece of JavaScript to take the content from one div and place it inside another.  You would normally hide the second div and probablt call the function when the page loads, but for the purposes of this demo, I'm showing both and am calling it on click.

First, place this in <script> tags in the head of your document, or in a separate JavaScript file:
function displayBox()
     if (document.getElementById("boxPosition") != null) {
         var boxContent = "";
             if (document.getElementById("boxContent").innerHTML != null) {
                 boxContent = document.getElementById("boxContent").innerHTML;
         document.getElementById("boxPosition").innerHTML = boxContent;
         document.getElementById("boxContent").style.display = "None";
Then place <div id="boxPosition"></div> where you want the content to appear. Put the content between <div id="boxContent"> and </div> and add onLoad="displayBox()" to your body tag. For this demo, I've allowed the content of the boxContent div to show, until you call the function, by clicking on the link, but if you are calling the function on load, you should hide the content with a disply:none style, to avoid it appearing briefly when the page first loads.

This is where the content actually is.

Monday, 1 August 2011

So What is this Blog About Then?

Well that is a very good question. I set this blog up months ago because I wanted to 'try blogging,' but I've only managed one post so far, and that simpley said "Hello World."

Don't worry I'm not going to bore you with what I had for breakfast or pictures of my cat. I don't even have a cat ;-).

I recently spent ages searching the web for a way to place the content of one div inside another. Once I found how to do it, I decided that would be my fisrt (well technically third) post.

Deciding to make that post helped me make the decision on what this blog will be about - web development.

I'll post anything related to web development that I think might be useful to other web developers.

Monday, 28 February 2011