16 Kasım 2010 Salı

Today, I was working on constructing a dynamic web page that allows user to add new paragraphs or links dynamically.

Here the basic way to add new elements to the webpage dynamically.



//we create a new paragraph element
newParag = document.createElement('p');
//we create a new text node
newText = document.createTextNode("Here the new paragraph");
//we add the text node inside the newly created paragraph element
newParag.appendChild(newText);
//Assume we have a division that has id 'content' and we
//call the 'content' division and add new paragraph to it
document.getElementById('content').appendChild(newParag);


That's all. Have a good life... see you:)

14 Kasım 2010 Pazar

To Determine the Size Of a Division Dynamically

I just add a option to my Google Extension that user can set the size of the application while he is using it. Here is the my work and the way to have this ability in my appli.

First assume we have a element in html that have the attribute " id = 'map' ".

First we add a new division to have three radio buttons to be selected for setting size.


<div id="options">
<form>
<input type="radio" name="size" onchange="setSize(400px, 600px)">400x600
<input type="radio" name="size" onchange="setSize(600px, 800px)">600x800
<input type="radio" name="size" onchange="setSize(100%, 100%)">FullScreen
</form>
<div>


We call setSize(--) function when we select one of the radio button. Then it is the time to define the setSize(--) function.



function setSize(h,w){
document.getElementById("map").setAttribute("style","height:"+h+"; width:"+w+";");
}



that is all...