If you are using Internet Explorer, hitting CTRL + F5 should suffice to fetch the latest versions.
No need to manually clear the browser cache.
If you are using Firefox or other Mozilla's children, hitting Shift+CTRL + R should fetch
the latest version with no need to clear the cache.
Filter
2006-11-05
Rensa cachen
Bra att veta
2006-10-13
Skapa HTML med DOM
DHTML
function buildTable(){
docBody = document.getElementsByTagName("body").item(0)
myTable = document.createElement("TABLE")
myTable.id ="TableOne"
myTable.border = 1
myTableBody = document.createElement("TBODY")
for (i = 0; i < 3; i++){
row = document.createElement("TR")
for (j = 0; j < 3; j++){
cell = document.createElement("TD")
cell.setAttribute("WIDTH","50")
cell.setAttribute("HEIGHT","50")
textVal = "Cell" + i + "_" + j
textNode = document.createTextNode(textVal)
cell.appendChild(textNode)
row.appendChild(cell)
}
myTableBody.appendChild(row)
}
myTable.appendChild(myTableBody)
docBody.appendChild(myTable)
}
window.onload = buildTable
/*
METHODS:
appendChild(child)
replaceChild(new,old)
removeChild(child)
insertBefore(new,ref)
EX:
newRow = document.createElement("TR")
tableBody = document.getElementById("myTableBody")
allRows = tableBody.getElementsByTagName("TR")
lastRow = allRows.item(allRows.length-1)
tableBody.insertBefore(newRow,lastRow)
hasChildNodes()
PROPERTIES:
nodeName
nodeType [element (1), attribute (2), text (3)]
nodeValue
parentNode
childNodes
firstChild
lastChild
OBS!
Fel:
removeChild("myTag")
Rätt:
removeChild(document.getElementById("myTag"))
S U M M E R I N G:
Document Methods:
------------------
getElementById(id)
Returns a reference to the named element.
getElementsByTagName(name)
Returns a collection of all matching elements in the document.
createElement(name)
Creates a new element of the type named.
createTextNode(text)
Creates a new node of pure text.
Element Methods:
------------------
getAttribute(id)
Returns the value of the named attribute.
setAttribute(id,value)
Assigns a new value to the attribute.
removeAttribute(id)
Removes the named attribute and its value.
getElementsByTagName(name)
Returns a collection of all matching elements in the node.
Node Methods:
------------------
appendChild(child)
Appends a new child node to the node.
removeChild(child)
Removes a child node from the node.
replaceChild(newChild,oldChild)
Replaces a child node with another one.
insertBefore(newChild,refChild)
Inserts a child node before another child node in the hierarchy.
hasChildNodes()
Returns a Boolean true if the node has children.
Node Properties:
------------------
nodeName
Contains the name of node as a string.
nodeType
Contains the type of the node as an integer.
nodeValue
Contains the value of the node in an applicable format.
parentNode
A reference to the parent node of this node.
childNodes
A collection containing references to all child nodes of this node.
firstChild
A reference to the first child node in the childNodes collection.
lastChild
A reference to the last child node in the childNodes collection.
*/2006-10-02
Effektivare css-kod
Css
/* background:
background-color, background-image, background-repeat, background-attachment, background-position */
body { background: yellow url(bg.gif) repeat-y 100% 0; }
/* border:
border-width, border-style, border-color */
h1 { border: 1px solid gray; }
/* font:
font-style, font-variant, font-weight, font-size, line-height, font-family */
h2 { font: italic small-caps bold 100%/120% arial, helvetica, sans-serif; }
/* padding o margin:
padding-top, padding-right, padding-bottom, padding-left
margin-top, margin-right, margin-bottom, margin-left */
h3 { padding: 4px; /* 4px runtom */
margin: 0 8px; /* ( 0px 8px 0px 8px ) */ }
h4 { padding: 2px 6px 3px /* 2px 6px 3px 6px */
margin: 1px 2em 3% 4en; }
/* list-style:
list-style-type, list-style-position, list-style-image */
ul { list-style: square inside; } 2006-09-25
Dynamiska data i Flash
Flash
/*
"texten" är ett dynamiskt textfält
Filen test.php innehåller URL-kodade get-parametrar
namn1=varde1&namn2=varde2 (kanske genererade från en databas)
*/
// Alt 1:
var lvData:LoadVars = new LoadVars();
lvData.load("test.php");
lvData.onLoad = function(bSuccess:Boolean):Void {
if (bSuccess) {
texten.text = this.namn1;
} else {
texten.text = "Default värde";
}
}
// Alt 2:
function showValues() {
texten.text = "returned from php: \n\n";
for (i in this) {
texten.text += this[i] + "\n";
}
}
var c = new LoadVars();
c.onLoad = showValues;
c.load("test.php"); 2006-09-25
Skicka variabler till Flash
Flash
<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "200", "100", "7", "#336699");
so.addVariable("variable1", "value1");
so.addVariable("variable2", "value2");
so.addVariable("variable3", "value3");
so.write("flashcontent");
</script> 