
function em_usun(nr) {
var el = document.getElementById(‘route_em_’+nr);
el.parentNode.removeChild(el);
}
div musi posiadac diva parent
<div>
<div id=”route_em_1″>div mapa polski</div>
<div id=”route_em_2″>div mapa polski</div>
</div>
<input type=”button” value=”" onclick=”em_usun(’1′)”>

<!DOCTYPE HTML PUBLIC „-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>
<title> New Document </title>
<script src=”debug_js.js” type=”text/javascript”></script>
<script language=”JavaScript”>
<!–
function getE(id) {
return document.getElementById(id);
}
function test() {
deb_write(deb_prop(getE(‘tests’),true));
}
function test2() {
var div = document.createElement(„span”);
div.style.font = ’12px Arial, Verdana, Tahoma’;
div.style.position = „absolute”;
div.style.background = ‘#fefefe’;
div.style.padding = ’2px’;
div.id = „s1″;
div.innerHTML = ‘Warszawa, Warszawa, Warszawa, Warszawa’;
var d2 = getE(‘tests2′);
d2.appendChild(div);
deb_write(deb_prop(getE(‘s1′),true));
}
//–>
</script>
</head>
<body>
<div id=”tests”>Polska Warszawa Polska Warszawa</div>
<div id=”tests2″></div>
<input type=”button” value=”Test” onclick=”test()”>
<input type=”button” value=”Test2″ onclick=”test2()”>
</body>
</html>

JavaScript:
var el = document.getElementById(‘mapa’);
var el2 = el.getElementsByTagName(‘a’)[0];
var value = el2.innerHTML;
alert(value);
HTML:
<div id=”mapa”><a href=”mapa.html”>mapa strony</a></div>
Wynik:
mapa strony

setTimeout( function(){ getElementById(‘msg’).style.display = ‘none’; }, 3000);
ukrycie, elementu „msg” po 3 sekundach (setTimeout -> 3000)

var cont = document.getElementById(‘content’).getElementsByTagName(‘div’);
for(i=0;i<cont.length;i++)
if (cont[i].className.match(/^belka/))
cont[i].style.display = ‘none’;
Przyklad ukrycia elementów, wykorzystanie match:
<div id=”content”>
<div class=”belka”>odnajdywanie klasa belki</div>
<div class=”belka”>odnajdywanie klasa belki></div>
</div>
<html>
<head>
<script type=”text/javascript”>
var IE = document.all ? true : false;
if (!IE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = myMouseXY;
var pX = 0;
var pY = 0;
function myMouseXY(e) {
if (IE) {
pX = event.clientX + document.body.scrollLeft;
pY = event.clientY + document.body.scrollTop;
} else {
pX = e.pageX;
pY = e.pageY;
}
if (pX < 0) pX = 0;
if (pY < 0) pY = 0;
document.getElementById(„ws”).value = pX+’,'+pY;
document.getElementById(„dymek”).style.left = pX;
document.getElementById(„dymek”).style.top = pY;
return true;
}
</script>
</head>
<body>
<div id=”dymek” style=”position: absolute;”><input type=”text” id=”ws”></div>
</body>
</html>

Przypisanie zdarzeń do tagów <td> tabeli
<script>
function add_tr_hover(id) {
alert(id);
var elem = document.getElementById(id);
var lista = elem.getElementsByTagName(‘tr’);
for(var i=0; i<lista.length; i++) {
lista[i].onmouseover=function() { this.style.backgroundColor=’#EDEDED’; }
lista[i].onmouseout=function() { this.style.backgroundColor=’#FFFFFF’; }
}
}
window.onload=function(){
add_tr_hover(„cos”);
}
</script>
Przykładowy HTML tabeli
<table id=”cos”>
<tr><TD>jeden</TD></tr>
<tr><TD>dwa</TD></tr>
<tr><TD>trzy</TD></tr>
<tr><TD>cztery</TD></tr>
<tr><TD>pięć</TD></tr>
</table>

map = new GMap2(document.getElementById(„mapcan”));
…..
map.getContainer().style.width = 500+’px’;
map.getContainer().style.height = 500+’px’;
map.checkResize();
Kod należy umieścić w funkcji JS.
Wywołanie funkcji powoduje zmiane rozmiaru mapy.

if(document.getElementById(‘the_iframe_map’)!=undefined)
parent.document.frames['the_iframe_map'].window.mappos(lat, lng);

function print_frag(id) {
var div;
div = document.getElementById(id);
okno = window.open(”, „”, „toolbar=0, location=0, resizable=1, directories=0, status=1, menubar=1, scrollbars=1, height=800, width=700, top=80, left=350′”);
var html = div.innerHTML;
html = ‘<html><head><link rel=”stylesheet” href=”http://kody.wig.pl/style.css” type=”text/css” /></head><body>’+html+’</body></html>’;
okno.document.write(html);
//okno.print();
okno.focus();
}
<a href=”javascript:print_content(‘fragment’)” mce_href=”javascript:print_frag(‘fragment’)”><b>Drukuj</b></a>
Strona zawiera sposoby oraz kody źródłowe pokazujące rozwiazanie napotkanych problemów