Centar za edukaciju-BiH


switch Lista naslova: Koristan JavaScript kod

#1 21.09.2010 21:45
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,644


Predmet:Koristan JavaScript kod
Kako koristiti kod.
Dovoljno je podici notepad i u njega nakoširati ovo:
<HTML>
<HEAD>
<TITLE>Neki naslov za title</TITLE>
</HEAD>
<BODY>
<!--<ispod ovoga kopirajte java kod-->

<!--Poslije java koda ovo ispod-->
</BODY>
</HTML>

Stranicu zaspisati kao html:
Primjer:
Mojprimjer.html
Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
Ovaj post je ureden 4 puta. Posljednja izmjena 12.10.2021 12:23 od strane zxz. ↑  ↓

#2 21.09.2010 21:49
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,644


Predmet:Kod za trazenje na stranici.
Kod za trazenje na stranici.


PreuzmiIzvorni kôd (Javascript):
  1. <script language="JavaScript">
  2. /*
  3. Nadji na stranici-
  4. Posjetite [URL="http://www.icentar.com/"]http://www.icentar.com[/URL]
  5. */
  6. var NS4 = (document.layers);    // Which browser?
  7. var IE4 = (document.all);
  8. var win = window;    // window to search.
  9. var n   = 0;
  10. function findInPage(str) {
  11.   var txt, i, found;
  12.   if (str == "")
  13.     return false;
  14.   // Find next occurance of the given string on the page, wrap around to the
  15.   // start of the page if necessary.
  16.   if (NS4) {
  17.     // Look for match starting at the current point. If not found, rewind
  18.     // back to the first match.
  19.     if (!win.find(str))
  20.       while(win.find(str, false, true))
  21.         n++;
  22.     else
  23.       n++;
  24.     // If not found in either direction, give message.
  25.     if (n == 0)
  26.       alert("Takve rijeci nema.");
  27.   }
  28.   if (IE4) {
  29.     txt = win.document.body.createTextRange();
  30.  
  31.     // Find the nth match from the top of the page.
  32.     for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
  33.       txt.moveStart("character", 1);
  34.       txt.moveEnd("textedit");
  35.     }
  36.     // If found, mark it and scroll it into view.
  37.     if (found) {
  38.       txt.moveStart("character", -1);
  39.       txt.findText(str);
  40.       txt.select();
  41.       txt.scrollIntoView();
  42.       n++;
  43.     }
  44.     // Otherwise, start over at the top of the page and find first match.
  45.     else {
  46.       if (n > 0) {
  47.         n = 0;
  48.         findInPage(str);
  49.       }
  50.       // Not found anywhere, give message.
  51.       else
  52.         alert("Takve rijeci nema.");
  53.     }
  54.   }
  55.   return false;
  56. }
  57. </script>
  58. <form name="search" onSubmit="return findInPage(this.string.value);">
  59. <font size=3><input name="string" type="text" size=15 onChange="n = 0;"></font>
  60. <input type="submit" value="Find">
  61. </form>

Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
↑  ↓

#3 21.09.2010 21:53
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,644


Predmet:Zabrana desnog klika misa.
Zabrana desnog klika misa.


PreuzmiIzvorni kôd (Javascript):
  1. <script language=JavaScript>
  2. <!--
  3. var message="Zabranjeno kopiranje!";
  4. ///////////////////////////////////
  5. function clickIE() {if (document.all) {alert(message);return false;}}
  6. function clickNS(e) {if
  7. (document.layers||(document.getElementById&&!document.all)) {
  8. if (e.which==2||e.which==3) {alert(message);return false;}}}
  9. if (document.layers)
  10. {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
  11. else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
  12. // -->
  13. </script>

Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
↑  ↓

#4 21.09.2010 22:00
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,644


Predmet:Otvara vasu stranicu u ful skrin.
Otvara vasu stranicu u ful skrin.


PreuzmiIzvorni kôd (Javascript):
  1. <SCRIPT TYPE="text/javascript" LANGUAGE="javascript">
  2. <!-- [URL="http://www.jahu.net/"]www.jahu.net[/URL] -->
  3. // ?irina i visina
  4. var windowW=screen.width  // ?irina
  5. var windowH=screen.height // visina
  6. // Pozicija pokazivanja, za fullscreen 0 i 0
  7. var windowX = 0
  8. var windowY = 0
  9. // Stranica koja ce se loadirati
  10.  
  11. var urlPop = "[URL="http://www.icentar.com/"]http://www.icentar.com[/URL]"
  12. // Naziv stranice
  13. // Promijeni webmajstor u svoj title
  14. var title =  "webmajstor"
  15. // =======================================
  16. // NE MIJENJAJTE NI?TA ISPOD!
  17. // =======================================
  18. var autoclose = true
  19. s = "width="+windowW+",height="+windowH;
  20. var beIE = document.all?true:false
  21. function openFrameless(){
  22.   if (beIE){
  23.     NFW = window.open("","popFrameless","fullscreen,"+s)    
  24.     NFW.blur()
  25.     window.focus()      
  26.     NFW.resizeTo(windowW,windowH)
  27.     NFW.moveTo(windowX,windowY)
  28.     var frameString=""+
  29. "<html>"+
  30. "<head>"+
  31. "<title>"+title+"</title>"+
  32. "</head>"+
  33. "<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
  34. "<frame name='top' src='"+urlPop+"' scrolling=auto>"+
  35. "<frame name='bottom' src='about:blank' scrolling='no'>"+
  36. "</frameset>"+
  37. "</html>"
  38.     NFW.document.open();
  39.     NFW.document.write(frameString)
  40.     NFW.document.close()
  41.   } else {
  42.     NFW=window.open(urlPop,"popFrameless","scrollbars,"+s)
  43.     NFW.blur()
  44.     window.focus()
  45.     NFW.resizeTo(windowW,windowH)
  46.     NFW.moveTo(windowX,windowY)
  47.   }  
  48.   NFW.focus()  
  49.   if (autoclose){
  50.     window.onunload = function(){NFW.close()}
  51.   }
  52. }
  53. //-->
  54. </SCRIPT

Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
↑  ↓

#5 21.09.2010 22:06
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,644


Predmet:Print taster.
Print taster.


PreuzmiIzvorni kôd (Javascript):
  1. <SCRIPT Language="Javascript">
  2.  
  3. function printit(){  
  4. if (window.print) {
  5.     window.print() ;  
  6. } else {
  7.     var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
  8. document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
  9.     WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
  10. }
  11. }
  12. </script>
  13. <SCRIPT Language="Javascript">  
  14. var NS = (navigator.appName == "Netscape");
  15. var VERSION = parseInt(navigator.appVersion);
  16. if (VERSION > 3) {
  17.     document.write('<form><input type=button value="Print" name="Print" onClick="printit()"></form>');        
  18. }
  19. </script>

Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
Ovaj post je ureden 1 puta. Posljednja izmjena 21.09.2010 22:07 od strane zxz. ↑  ↓

#6 21.09.2010 22:45
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,644


Predmet:Grad edit bar
Grad edit bar



PreuzmiIzvorni kôd (Javascript):
  1. <script language="JavaScript1.2">
  2. <!--
  3. /*
  4. Gradient Bar Script (By Alex Szorkovszky [EMAIL="alex@wmresources.com"]alex@wmresources.com[/EMAIL])
  5. */
  6. if (document.all){
  7. one=new Array();
  8. two=new Array();
  9. var a=10;var b=11;var c=12;var d=13;var e=14;var f=15;
  10.  
  11. //Promijenite gradijent
  12. //Duzinu i visinu gradienta
  13. var width = 350;
  14. var height = 20;
  15. //broj pixela izmedju boja
  16. var gap = 5;
  17. //0 za horizontal, 1 za vertical
  18. var direction = 0;
  19. //broj boje 1 - upisi 1-vo, 3-ce i 5-ti broj/slovo colour coda
  20. one[0]=f;
  21. one[1]=9;
  22. one[2]=0;
  23. //broj boje 2 - upisi 1-vo, 3-ce i 5-ti broj/slovo colour coda
  24. two[0]=c;
  25. two[1]=c;
  26. two[2]=c;
  27.  
  28. //kraj konfiguracije
  29.  
  30. if(direction==0) var num = width / gap;
  31. if(direction==1) var num = height / gap;
  32. color2=new Array();
  33. color1=new Array();
  34. diff=new Array();
  35. for(i=0;i<3;i++) {
  36. diff[i] = two[i] - one[i];
  37. diff[i] = diff[i] / num;
  38. }
  39. for(i=0;i<3;i++){
  40. color1[i] = Math.round(diff[i] * Math.pow(10, 0));
  41. if(color1[i] > diff[i])color1[i] = color1[i] - 1;
  42. color2[i] = diff[i] - color1[i];
  43. color2[i] = color2[i] * 15;
  44. color2[i] = Math.round(color2[i] * Math.pow(10, 0));
  45. }
  46. x=new Array();
  47. two[0]=0;
  48. two[1]=0;
  49. two[2]=0;
  50. document.write('<table border="0" cellpadding="0" cellspacing="0" width="'+width+'" height="'+height+'">');
  51. if(direction==0) document.write('<tr>');
  52. for(i=0;i<=num;i++) {
  53. if(direction==1) document.write('<tr>');
  54. document.write('<td bgcolor="#');
  55. for(j=0;j<3;j++) {
  56. if(one[j]==a)document.write("a");
  57. if(one[j]==b)document.write("b");
  58. if(one[j]==c)document.write("c");
  59. if(one[j]==d)document.write("d");
  60. if(one[j]==e)document.write("e");
  61. if(one[j]==f)document.write("f");
  62. if(one[j]<10)document.write(one[j]);
  63. if(two[j]==a)document.write("a");
  64. if(two[j]==b)document.write("b");
  65. if(two[j]==c)document.write("c");
  66. if(two[j]==d)document.write("d");
  67. if(two[j]==e)document.write("e");
  68. if(two[j]==f)document.write("f");
  69. if(two[j]<10)document.write(two[j]);
  70. one[j] = one[j] + color1[j];
  71. two[j] = two[j] + color2[j];
  72. if(two[j]>15) {
  73. two[j] = two[j] - 15;
  74. one[j]++;
  75. }
  76. }
  77. if(direction==0) document.write('" width="'+gap+'" height="'+height+'"> </td>');
  78. if(direction==1) document.write('" width="'+width+'" height="'+gap+'"> </td></tr>');
  79. }
  80. document.write('</table>');
  81. }
  82. //-->
  83. </script>

Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
↑  ↓

#7 02.10.2010 19:13
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,644


Predmet:Printanje stranice
Ako vam treba printanje vase stranice odnosno da napravite taster print onda koristite ovaj kod.

PreuzmiIzvorni kôd (Javascript):
  1. <script Language="Javascript">
  2.  
  3. function printit(){  
  4. if (window.print) {
  5.     window.print() ;  
  6. } else {
  7.     var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
  8. document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
  9.     WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
  10. }
  11. }
  12. <script Language="Javascript">  
  13. var NS = (navigator.appName == "Netscape");
  14. var VERSION = parseInt(navigator.appVersion);
  15. if (VERSION > 3) {
  16.     document.write('<form><input type=button value="Print" name="Print" onClick="printit()"></form>');        
  17. }

Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
Ovaj post je ureden 1 puta. Posljednja izmjena 04.03.2012 00:29 od strane zxz. ↑  ↓

#8 18.02.2011 02:00
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,644


Predmet:Dijalog box OK Cancel
Kod dolazi unotar Body u html.
PreuzmiIzvorni kôd (Javascript):
  1. <script type="text/javascript">
  2. var ime = confirm("Pritisnite gumb")
  3. if (ime == true)
  4. {
  5. document.write("Pritisnuli ste OK")
  6. }
  7. else
  8. {
  9. document.write("Pritisnuli ste Cancel")
  10. }
  11. </script>

Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
↑  ↓

#9 18.02.2011 02:02
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,644


Predmet:Input Box
Kod postaviti izmedju Body u HTML
PreuzmiIzvorni kôd (Javascript):
  1. <script type="text/javascript">
  2. var ime = prompt("Unesite svoje ime","")
  3. if (ime != null && ime != "")
  4. {
  5. document.write("Dobrodošli " + ime)
  6. }
  7. </script>

Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
↑  ↓

#10 18.02.2011 02:14
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,644


Predmet:Otvaranje novog prozora
Prekopirajte kod u TxT file i dajte mu extenziju html.
PreuzmiIzvorni kôd (Text):
  1. <HTML>
  2. <HEAD>
  3. <META NAME="generator" CONTENT="toniarts easyhtml v.2.4">
  4. <TITLE>Title of your page</TITLE>
  5. </HEAD>
  6. <BODY>
  7. <script type="text/javascript">
  8. function prozor()
  9. {
  10. window.open("http://www.google.com","moje_novo_okno","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=300, height=300")
  11. }
  12. </script>
  13.  
  14. <form>
  15. <input type="button" value="Otvori prozor" onclick="prozor()">
  16. <a href="javascript:prozor()">Otvori ba</a>
  17. </form>
  18. <br />
  19. </BODY>
  20. </HTML>

PreuzmiIzvorni kôd (HTML):
  1. <!DOCTYPE html>
  2. function OtvoriProzor()
  3. {
  4. var MojProzor = window.open("","","width=200,height=100");
  5. MojProzor.document.write("<p>ovo je 'MojProzor'</p>");
  6. MojProzor.focus();
  7. MojProzor.document.write("<p>E ovo je novi prozor</p>");
  8. }
  9. </head>
  10.  
  11. <button onclick="OtvoriProzor()">OtvoriProzor</button>
  12.  
  13. </body>
  14. </html>

Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
Ovaj post je ureden 1 puta. Posljednja izmjena 02.01.2014 09:44 od strane zxz. ↑  ↓

Stranice (7):1,2,3,4,5,6,7


Sva vremena su GMT +01:00. Trenutno vrijeme: 8: 48 pm.