Jump to content

raimo

Members
  • Posts

    132
  • Joined

  • Last visited

Everything posted by raimo

  1. argh! sorry! var myDate = new Date();myDate.setMonth(myDate.getMonth() + 1);myDate.setDate(myDate.getDate() - 14);alert(myDate.getDate() + '/' + myDate.getMonth() + '/' + myDate.getFullYear()); should work OK now? :)edit:-24 -> -14
  2. You need first set new Date to date/time needed and then split that setted date to DD/MM/YYYY: var myDate = new Date();myDate.setDate(myDate.getDate() - 14);document.write(myDate.getDate() + '/' + myDate.getMonth() + '/' + myDate.getFullYear());
  3. I'm not sure, but I think application/octet-stream is better?there is no mime-type application/jpg in my Linux mime.types,but application/octet-stream there is and it works fine with all images (all binary-files).Perl is beautiful:#!/usr/bin/perl$fname = "image1.png";open FILE, $fname or die $!; local $/; $file = <FILE>;close FILE;print "Content-type: application/octet-stream\n";print "Content-Disposition: attachment; filename=somename.png\n\n";print $file;# somename.png is only as "save name", it could be same as $fname or something else.
  4. raimo

    Css layout

    I'm not sure what You are doing? :)try:display: inline;You can't say:margin-bottom:1; or height:128; there must allways be measuring unit with all other values than zero (px, em, cm ..)Real browsers will drop attributes without unit to the trash.margin-bottom: 1px;
  5. Here we go, POST with Javascript! function ajaxRequest(url, post){var request = false;try{request = new XMLHttpRequest(); //All Gecko's and Opera} catch(error){}try{request = new ActiveXObject('Msxml2.XMLHTTP'); //MSIE} catch(error){}try{request = new ActiveXObject('Microsoft.XMLHTTP'); //MSIE} catch(error){}request.onreadystatechange = function(){ if (request.readyState == 4){ document.getElementById('ajax').innerHTML = request.responseText; return true; }}request.open('POST', url, true);request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.setRequestHeader("Content-length", post.length); request.setRequestHeader("Connection", "close"); request.send(post);return true;} There is still innerHTML, You can change it to DOM as my 1st post was done.XHTML: <div id="ajax"><!-- request.responseText will come here after POST --></div><button onclick="ajaxRequest('yourphp.php', 'data1=Hello world!&data2=AJAX rocks!')">Send POST</button> AJAX rocks!
  6. If You are using NOAA there is FTP anonymous server :)Get weather from there with PHP and FTP.URLs: ftp://weather.noaa.gov/data/observations/metar/stations/ftp://weather.noaa.gov/data/observations/metar/decoded/where XXXX.TXT as EETN.TXT is Estonia TallinnThis one may not help in Your case, but do not use iframe, use div! :)Here is example how You can do file include with Javascript to div or any other element:Live server is needed to operate with this beauty, and You can include only from Your own domain level.function ajaxInclude(file){var request = false; try{ request = new XMLHttpRequest(); //All Gecko's and Opera } catch(error){} try{ request = new ActiveXObject('Msxml2.XMLHTTP'); //MSIE } catch(error){} try{ request = new ActiveXObject('Microsoft.XMLHTTP'); //MSIE } catch(error){}request.open('GET', file, false); request.send(null); if (request.status == 200) return request.responseText else return 'Error: ' + request.status;}function Open(obj){var e = document.getElementById('ajax'); if (!e.firstChild){ var baby = document.createTextNode('&#32;'); e.appendChild(baby); } e.firstChild.nodeValue = ajaxInclude(obj.value);obj.selectedIndex = 0;} <div id="ajax"></div>No Microsoft innerHTML used! :blink:This one is used with select element like:<select onchange="Open(this)"><option value="data/default.txt">Select data</option><option value="data/a/file1.txt">1</option><option value="data/a/file2.txt">2</option></select>I will add POST example, at shortly, when get my nicotine-level back to normal
  7. edit: removed all, Scott wrotes same as I, again! if need to reset selection: <select name="choice" size="1" onchange="if (this.selectedIndex != 0) window.open(this.value); return this.selectedIndex = 0" > I mean if You have:<option value="#">Select location</option><option value="http://www.fi/">Mother knows everything</option><option value="http://www.ru/">Russia on the Net</option>etc . select will be reseted to Select location option (o) after each changeUse function,Javascript to head part of Your document: <script type="text/javascript"><!--function Open(obj){if (obj.selectedIndex != 0) window.open(obj.value);obj.selectedIndex = 0;}//--></script> HTML:<select onchange="Open(this)">
  8. Lie? I learn it from W3C http://www.w3.org/TR/xhtml11/doctype.htmlStyle Attribute Module DeprecatedThere is more incoming! They (W3C) are hunting img tag now, it will be changed to "embedded object(attribute)". But first ALL styles and scripts will be removed from XHTML-document. That's the way things go in future.edit:sorry, img won't be as object tag: hard to say what this is, it's as an image embedded to p -tag <p src="pic1.png" srctype="image/png">my 1st XHTML2 photo</p>
  9. If I was You I would filter out the numbers like this: function noNumbers(e){try{var key = (e.which) ? e.which : event.keyCode} catch(err){}return ((key == 8 || key > 31) && (key < 48 || key > 57));} Just added try/catch block when I found that Linux has some odd event with numpad keys.(some event causes undefined error)Please use onkeypress, it works much better than onkeydown:<input type="text" onkeypress="return noNumbers(event)" />edit:sorry, You are reading tutorial of events, not filttering numbers? Anyway, in this (my private) tutorial we learn how to play with events and errors and etc.
  10. Hide other scrollbar? How? I have no idea how to do it.But scroll ta2 when ta1 scrolls and on contrary?I think textarea has no onscroll event? (with MSIE it has, but not within the real browsers).So we should try something else, like onmousedown or onmouseup.<textarea id="ta1" onmousedown="document.getElementById('ta2').scrollTop = this.scrollTop">textarea1Litlle Goat says: IE is fine!where is the cat?cat is in the moon! :owho are you?</textarea><textarea id="ta2" onmousedown="document.getElementById('ta1').scrollTop = this.scrollTop">textarea2raimo says: Opera is finest!;)gerbils are my friendsme tarzan you jane?snow is gone</textarea> if there is no need scroll ta1 when ta2 scrolls remove onmousedown-code of ta2Tested only with Firefox (linux version), and works somehow.
  11. hmm? a{text-decoration: none;}#content ul li a:hover, #content ul li a:visited,#content ul li a:active,#d1 .b1:hover{border-bottom: dotted 2px #FF8080;}#content ul li.l1 a:visited:hover{ /* if hover happend with visited link in li-element with class l1 */border-bottom: dotted 2px #80FF80;} #content ul li.l1 a:visited:hover case:<div id="content"><ul><li><a href="#">red bottom border</a><li class="l1"><a href="http://google.ru/">green bottom border when is visited and hover happend</a></li></ul></div>#d1 .b1 case is:<div id="d1"><b>not border</b><b class="b1"><a href="#">dotted bottom border when hover happend</a></b></div>Get Firefox Console2 extension, my friend! (all of You) It's a very powerfull CSS error huntig tool. https://addons.mozilla.org/extensions/1815edit: here is other good extension-tool for Javascript, CSS, HTML, Ajax.. FireBug: https://addons.mozilla.org/addon.php?id=1843
  12. Like all other iformation You can imagine, You can find with Google. :)1st link search-engine found goes to MSDN (Microsoft Developer Network) and there is all information needed. Google search: http://www.google.com/search?q=execCommand()execCommand "runs" commands on document, selection or range.and it works only with MSIE : so it can't be used seriously in real world.Here is other link where You can find all commands You can exec with it:http://msdn.microsoft.com/workshop/author/.../commandids.aspTutorial how to build WYSIWYG editor with execCommand:http://www.devguru.com/features/tutorials/...g/wysiwyg1.html
  13. DOM-code is ready, no tags or anything else need to add:Copy-paste the code from code-box and save it to file named iframe.jsthen in Your HTML say:<script src="iframe.js" type="text/javascript">//</script>where ever You need iframe (change name and id in DOM-code). No any other tags needed in HTML.Change Your URL here:iframe.setAttribute('src', 'http://www.google.ru/');If there is problems with height change this:iframe.setAttribute('height', '100%');to this:iframe.setAttribute('height', screen.height);or even this:iframe.setAttribute('height', screen.height + 500);
  14. or create it with DOMvar iframe = document.createElement("iframe");iframe.setAttribute('height', '100%');iframe.setAttribute('width', '100%');iframe.setAttribute('scrolling', 'no');iframe.setAttribute('frameborder', 0);iframe.setAttribute('marginwidth', 1);iframe.setAttribute('marginheight', 1);iframe.setAttribute('allowtransparency', 'true'); //MSIE transparent backgroundiframe.setAttribute('id', 'I1');iframe.setAttribute('name', 'I1');iframe.setAttribute('longdesc', '');iframe.style.border = 'none';iframe.setAttribute('src', 'http://www.google.ru/');document.getElementsByTagName("body")[0].appendChild(iframe);
  15. I'd explain it at the bottom of my post, but I can do it again, no problem: We have referrer: http://w3schools.invisionzone.com/not_exis...ct=Post&CODE=02var x = document.referrer.split('/'); splits referrer from every / - mark to the array.so we have x called array who is eatting these stuff:x[0] = http:x[1] = x[2] = w3schools.invisionzone.comx[3] = not_existsx[4] = index.php?act=Post&CODE=02and then x = x[x.length - 1]; takes always the last one (x[4] in this case) to handle as a filename, andx = x.split('?') slits away ? and rest of query part of URL, so now we have x = index.phpLast one (? split) can be "not needed", but I'm not sure how all browsers handles referrer,so it's there just in case.If it still not working, look first the referrer with alert(document.referrer); and thenwith alert(x); what is happening every part of the script.Anyway, I'd test it with my live server and it works OK. :)Big help is if You use Firefox, there is Tools -> Javascript Console (or Error console) try to catch errors whit it. Opera console: Tools -> Advanced -> Error consoleRemember, there is always someones (etc Opera users in very easy way) who are blocking to show referrer, so this kind of referrer-sniffing-system is not fullproof, not at all.
  16. hmmm?is there some kind of invisible "system"? or how all colors and background-colors are missing in CSS file?there is illegal background-color:; and color:; almost very many times! :)Look it with this:http://jigsaw.w3.org/css-validator/validat...links_style.phpthislegend.statset_title a { background-color:; }should be:legend.statset_title a { background-color: inherit; }orlegend.statset_title a { background-color: #808080; }orlegend.statset_title a { background-color: red; }but not this:legend.statset_title a { background-color:; }that will do big error and CSS will be dropped:
  17. referrer is as a whole URL, so we need to split it a smaller bits.function checker(){var x = document.referrer.split('/');x = x[x.length - 1];x = x.split('?'); // just in case there is query incoming if (x == "test.html" || x == "wishlist.html" || x == "prodblank.html" || x == "form.html" || x == "123.html" || x == "index.html"){ return true; } else { window.location = "index.html"; return false; } } Cleaned up it a bit, and remover unneeded () and added couple ; -marks.This line splits URL to the array via / -marks of URL:var x = document.referrer.split('/');this line takes last element of array and puts it as a filename:x = x[x.length - 1];tested with live server, and works.edit:Blue was there before me, I was late again, but so what?
  18. Basicly it does very cool things! like creates ComboBox(es), adds and remove items of those combos, sets properties etc. Waiting next version... Play with these:<button onclick="cb.Items.Add('Jonas', 'something')">Add Jonas</button><button onclick="cb.Items.Remove('Jonas')">Remove Jonas</button>By the way there is small bug, if 124 Jonas is added, Revove Jonas button removes more than one Jonas in each click. But it's not ready yet, public beta or similar. :)Opera 9 is now public beta too: http://opera.com/pressreleases/en/2006/04/20/
  19. Do not use inline CSS with XHTML, it's going to be as a W3C deprecated way to do things.External CSS file is very cool, You can easily add styles of huge set of pages within one style-file.OK, this time I can do it with inline CSS, but for example purposes only. <div style="margin: 0 auto; width: 500px; text-align: center"><img src="pic1.png" alt="pic1" /></div>
  20. This one will work! :)Head -part: (or rather external CSS -file, without style-tags)<style type="text/css"><!--.imgs{margin: 0 auto;width: 500px;text-align: center;}--></style> Body -part:<div class="imgs"><img src="pic1.png" alt="pic1" /></div>if You (or someone) is using MSIE older than 6.x set body text-align to center.Remember as a proper DTD with URL, DTD has effects with MSIE 6.x and margin auto.
  21. You should look Your code. Don't blame Firefox, there is nothing wrong with it, but Your code is broken.There is no quick way if Your code is full of errors, the one and only way is fix the code.Validate it until there is 0 warnings, then it will work just fine with all browsers.Here is validator link to Your pages:http://validator.w3.org/check?uri=http%3A%...thix.t35.com%2FCouple things:Document type declaration is missing. Add this to the first line of Your code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">it must be before <html> tag in every HTML-document.Table has no height property. (if You need set table height use CSS: style="height: 200px")With HTML You can not use px etc. units, those units can be used only with CSS.Table align can't be left and top, especially it can't be top! <table align=left align=top border=2 cellpadding=3 cellspacing=3 width=150px height=250px>all " -marks are missing, should be something like this:<table align="left" border="2" cellpadding="3" cellspacing="3" width="150" summary="my first table" style="height: 250px"><td><center><a href=index.html>Home</center></a></td>tags are in wrong order, should be:<td><center><a href="index.html">Home</a></center></td>Counted 81 pcs. this kind of errors with Tidy.Advice: remove center and font -tags, and use CSS. Remove all those not needed javascript etc. tricks .. until You learn how to use HTML and CSS in right way.
  22. Sorry, but it will work with Opera! Tested with Opera 8.51, 8.52, 8.53 8.54 in Windows and newest Opera 9 TP2 (236) in Linux. This one will work with all those just fine:<script type="text/javascript"><!--var table = document.createElement('table'); table.setAttribute('width', 500); table.setAttribute('id', 'table1'); table.style.border = 'solid 2px #808080'; tr = document.createElement('tr'); for (var i = 0; i < 3; i++){ td = document.createElement('td'); td.style.backgroundColor = '#FF8080'; text = document.createTextNode('cell ' + i); td.appendChild(text); tr.appendChild(td); }table.appendChild(tr);document.getElementsByTagName("body")[0].appendChild(table);//--></script> but it will not work with MSIE.
  23. var myarray = new Array(3); // main arrayfor (var i = 0; i < 3; i++) myarray[i] = new Array(3); // sub arrays now we own 3 arrays with 3 sub arrays: myarray[0] -> [0][1][2]myarray[1] -> [0][1][2]myarray[2] -> [0][1][2] myarray[0][0] = "horse";myarray[1][2] = "cat";myarray[2][1] = "dog";if (myarray[2][1] == "dog") alert(myarray[0][0]); etc. hope this help?
  24. raimo

    Problems with IE 6/7

    There is keywords!Please do not use IE 7 to testing Your pages, there is huge heap bugs within it.I mean, until it's ready we not should mind if it is working in wrong way ->we should not try build sites work with beta-version browser.
  25. Yes it is.<a href="#" onclick="document.forms['form1'].submit()">Submit</a>or<a href="java script:document.forms['form1'].submit()">Submit</a><form name="form1" action="" method="post">
×
×
  • Create New...