JavaScript - Jquery Doesn't Work In Ie9 Or Latest Chrome Dev
This is puzzling me.
It's an incremental search function. Any help for a Javascript novice much appreciated: Code: $(function () { $('#quickFilter').incrementalFilter({ items: 'dl.entryList > dt', foundCounter: '#resultCount', totalCounter: '#totalCounter', minChars: 2 }).focus(); }) ... here's the rest of it: Code: (function($) { var IncrementalFilter = function(params){ var setting = this.setting = { input: undefined, items: undefined, searchScope: '*', minChars: 2, useHighlight: true, foundCounter: undefined, totalCounter: undefined, highlightElem: $('<em class="highlight" />'), foundClass: 'found', zeroClass: 'zero' } $.extend(setting,params) this.input = $(setting.input); this.items = $(setting.items); this.minChars = setting.minChars; if(setting.foundCounter){ this.totalCounter = setting.totalCounter; this.foundCounter = new IncrementalFilter.Counter(setting); } this.formerQuery = ''; this.itemData = []; this.init(); } IncrementalFilter.prototype = { makeData: function(){ var that = this; this.items.each(function(){ var obj = [$(this)] if($(this).is('dt')){ obj.push($(this).next()) } that.itemData.push(new IncrementalFilter.SearchedItem(obj,that.setting)); }) if(this.foundCounter){ this.foundCounter.refresh(this.itemData.length); if(this.totalCounter){ $(this.totalCounter).html(this.foundCounter.all) } } }, processQuery: function(query){ var tempq = this.escapeQuery(query) tempq = $.trim(tempq).split(/\s+/); var queries = [] for(var i=0,l=tempq.length;i<l;i++){ for(var j=0,m=tempq.length;j<m;j++){ if(i!=j && tempq[i] && (tempq[i] == tempq[j] || RegExp(tempq[i]).test(tempq[j]) || tempq[i].length < this.minChars)){ tempq.splice(i,1) l = m = tempq.length; } } if(tempq[i]){ queries.push(tempq[i]) } } if(queries.join(' ') != this.formerQuery){ this.search(queries); this.formerQuery = queries.join(' '); } }, escapeQuery: function(query){ var escapeChars = '.+*^$?()[]{}'; var res = query; for(var i=0,l=escapeChars.length;i<l;i++){ var ec = escapeChars.charAt(i); res = res.replace(RegExp('\\'+ec,'g'),'\\'+ec); } return res; }, search: function(queries){ var that = this; var count = 0; $(that.itemData).each(function(){ var self = this; var matchCount = 0; $.each(queries,function(){ if(RegExp(this,'i').test(self.text)) matchCount++; }) if(matchCount == queries.length){ this.showItem() this.clearHighlight(function(){ $.each(queries,function(){ self.highlightWord(this) }) }); count++; }else{ this.hideItem(); } }) if(this.foundCounter){ this.foundCounter.refresh(count) } }, reset: function(){ var that = this; $(this.itemData).each(function(){ this.showItem(); this.clearHighlight(); if(that.foundCounter){ that.foundCounter.reset(); } }) }, setEvent: function(){ var that = this; this.input.bind('keyup',function(){ var val = $(this).val(); if(val.length >= that.minChars){ that.processQuery(val) }else{ that.reset(); } }) }, init: function(){ this.makeData(); this.setEvent(); if(this.input.val().length >= this.minChars){ this.processQuery(this.input.val()) } } } /** *@param obj {array} **/ IncrementalFilter.SearchedItem = function(obj,setting){ this.useHighlight = (setting.useHighlight && $.fn.highlightText && $.fn.removeOuterTag) if(this.useHighlight){ this.highlightElem = setting.highlightElem || $('<em class="highlight" />'); this.highlightExpr = /^<(\w+)/.exec($('<div />').append(this.highlightElem).html())[1] + '.'+this.highlightElem.attr('class').split(/\s/).join('.'); } this.text = ''; this.obj = []; for(var i=0,l=obj.length;i<l;i++){ var temp = obj[i]; this.obj[i] = {'elem':temp,'orgsrc':temp.html()} this.text += obj[i].text(); } } IncrementalFilter.SearchedItem.prototype = { hideItem: function(){ $(this.obj).each(function(){ this.elem.hide(); }) return this; }, showItem: function(){ $(this.obj).each(function(){ this.elem.show(); }) return this; }, clearHighlight: function(callback){ if(!this.useHighlight) return this; var that = this; $(this.obj).each(function(){ $(that.highlightExpr,this.elem).removeOuterTag() }) if(callback) callback(); return this; }, highlightWord: function(word){ if(!this.useHighlight) return this; var that = this; var query = new RegExp(word,'gi') $(this.obj).each(function(){ this.elem.highlightText(query,that.highlightElem) }) return this; } } IncrementalFilter.Counter = function(setting){ if(!setting || !setting.foundCounter) return undefined; this.obj = $(setting.foundCounter); this.foundClass = setting.foundClass || 'found'; this.zeroClass = setting.zeroClass || 'zero'; this.all = undefined; this.refresh = function(count){ this.obj.html(count); if(!this.all){ this.all = count; } if(count == 0){ this.zero() }else if(count < this.all){ this.highlight(); } } this.reset = function(){ this.refresh(this.all); this.obj .removeClass(this.foundClass) .removeClass(this.zeroClass) } this.highlight = function(){ this.obj .removeClass(this.zeroClass) .addClass(this.foundClass) } this.zero = function(){ this.obj .removeClass(this.foundClass) .addClass(this.zeroClass) } return this; } $.fn.incrementalFilter = function(params){ return this.each(function(){ if(typeof params == 'string' || params.size){ new IncrementalFilter({input:$(this),items:params}) }else if(typeof params == 'object'){ params.input = $(this); new IncrementalFilter(params) } }); }; Similar TutorialsHi every one, i'm new in this forum and also quite new in coding i wrote some code to login and register with php, also using some function with javascript, everything worked fine also with chrome, but suddenly, without change of any code, chrome doesn't activate js functions while FF and IE do activate them. can anyone suggest what could be the reason? ---Edit: as suddenly as it stopped, now it working again. chrome works in mysterious ways... I'm new to the forum. So hi everyone. The code below works fine on IE and FF but not on Google Chrome. Can someone tell me where I'm doing wrong? Thank you for your answers in advance. Im really looking forward much to hearing from you. You can preview the below code by pasting it to Frontpage, Dreamweaver and etc. Quote: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/JavaScript"> <!-- function show(id) { if (document.getElementById(id).style.display == 'none') { document.getElementById(id).style.display = ''; } } //--> <!-- function hide(id) { document.getElementById(id).style.display = 'none'; } //--> </script> </head> <body> <div> <div> <table cellspacing="1" cols="3" border="0"> <tbody> <td><a onfocus="hide('tblB');hide('tblC');show('tblA');" href="#">A</a> <td><a onfocus="hide('tblA');hide('tblC');show('tblB');" href="#">B</a> <td><a onfocus="hide('tblB');hide('tblA');show('tblC');" href="#">C</a> </td> </tr> </tbody> </table> </div> <div> <table id="tblA" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select A, table tblA is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblB" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select B, table tblB is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblC" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select C, table tblC is shown </td> </tr> </tbody> </table> </div> </div> </body> </html> Hi there, I hope I post this in the right section. I'm trying to do a redirect using the below code: <script type="text/javascript"> window.location.href = "http://google.com" </script> FF and IE work as they should. Chrome doesn't. The request above to http://google.com, gets a 'canceled' status in Chrome browser > Development tools > "Network". I've tried several other functions: location.href = url location.replace(url) document.location = url location.assign(url) window.open(url, '_self') Same code pasted within a local html file works fine. Below is the redirect request that it's canceled by chrome: http://pastebin.com/hD36M1RG Any clues? Thanks Hello, I'm trying to combine two different jQuery scripts on my webpage. The one is showing flashvideos in a lightbox and the other one is displaying thumbnails in a slideshow. The problem is that only one script is working. I have searched the web and forums and found that several people have had this problem before and I have truly tried to fix it with noConflict(). The problem is that I have very little experience in Javascript so I haven't got it working. So, here are the lines in the code: <!-- Video lightbox --> <script type="text/javascript" src="/js/videolightbox/mootools.js"></script> <script type="text/javascript" src="/js/videolightbox/swfobject.js"></script> <script type="text/javascript" src="/js/videolightbox/videobox.js"></script> <!-- Thumbnail slider --> <script type="text/javascript" src="/js/jquery-1.2.6.js"></script> <script type="text/javascript" src="/js/carousel.js"></script> I haven't coded any of these myself (of course), so I am not familiar with the variables in the files. So my target is to find a way to to use these scripts simultaneously. I am very thankful for your help but I am also kindly asking for a simple and easy to understand instruction. The webpage can be found he http://wearethemusicmakers.se/index2.php Best Regards Johannes well the jquery is working fine for twitter and other stuff but its not working for facebook, when i highlight the text and select fb to share at then the facebook share just show the meta description of site and not the selected area. I am not able to understand where am i going wrong, any assistance provided is highly appreciated. Go to this link http://www.blobh.com/2011/09/testing-1.html there select some text then a tooltip kind of thing will appear first share at twitter then at facebook you will understand the matter. the script i am using is this Code: <script type='text/javascript'> $('.demo1').selectedTextSharer({ lists:"Twitter,http://twitter.com/home?status=%ts ,favicon|Facebook,http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.blobh.com%2F&t=%s,favicon|Wikipedia (en),http://en.wikipedia.org/w/index.php?title=Special:Search&search=%s,favicon|Google Maps,http://maps.google.com/?q=%s,favicon", extraClass: 'dark', title: 'Share this text ...', borderColor: '#7F241C', background : '#4F663A', titleColor : '#7F241C', textColor : '#FFFFFF', hoverColor: '#7F241C' }); </script> and the other script is this one http://bloghuts.googlecode.com/files...-sharer.min.js and the html is like this Code: <!-- Just wrap a text with a div and add a class, thats all ! --> <div class="demo1"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it</div> <textarea class="demo4"></textarea> <input class="demo4" type="text" /> Hello to all, I think that you will frequently read this boring sentence: "Javascript does not work with Firefox". Below a very very simple html with Javascript. Using MS IE v8 I have found that the code works very well. Filling nothings in the textfield "your name" and subsequently clicking on the button and a window will popup with the text "Sorry, you forget to: blah-blah ..." However, using Firefox instead...it does not work. A bit remarkable; the Javascript is very easy! Could you please check what went wrong? I have activated Javascript in the Firefox browser and the security is ok for Javascript. I hope that someone can provide me a useful hint. Best regards, Cornelis The Netherlands - Gouda (yes, the town where cheese is inherently linked) [CODE] <html> <head> <meta http-equiv="Content-Language" content="nl"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Inloggen van een nieuw lid</title> <script language = "Javascript"> function checkDate() { var message = "Sorry, you forget to: \n"; var voornaam = document.getElementById("voornaam"); var result = true; if (voornaam.value.length == 0) { message+="- You have not typed your name\n"; result = false;} if(!result) {alert(message)}; return result; } </script> </head> <body> <FORM METHOD="post" name=CheckDate onsubmit="return checkDate(this);" > <div style="position: absolute; width: 603px; height: 378px; z-index: 1; left: 30px; top: 13px" id="laag1"> <p align="center"><font face="Trebuchet MS" color="#00750F" size="5"><b> Test</b></font></p> <table border="0" width="100%" bgcolor="#C4FFC4" style="border-collapse: collapse" id="table3"> <tr> <td> </td> </tr> </table> <p align="left"> </p> <table border="0" width="69%" id="table1" height="210" style="border-collapse: collapse"> <tr> <td width="37%"><font face="Trebuchet MS">your name</font></td> <td width="59%"> <p align="center"><input type="text" name="voornaam" size="25"></td> </tr> <tr> <td colspan="2" height="90"> <p align="center"> <input type="submit" value="Register me" name="Registreren"> </td> </tr> </table> <p> </p> </div> </body> </form> </html> So, i have this code which retrieves php files for me using jquery and id love to get it working with Jquery history plugin. I tried modifying the code i got from the ajax demo to work for me, but i just couldnt do it as i do not know any javascript really.. ( actually what i tried was simply to change "#ajax-links a" to "#menu li a" and .html to .php ..but nothing.. :rolleyes: Id be very gratefull if someone would help me out with this one. All related code can be found bellow (the ones that should be needed anyways): This is the code that retrieves php files inside "#content" when item from "#menu li a" with the specified id is clicked Code: $(document).ready(function(){ //References var change = $("#menu li a"); var loading = $("#loading"); var content = $("#content"); //Manage click events change.click(function(){ //show the loading bar showLoading(); //load selected section if(this.id == "home") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/index.php", hideLoading); content.slideDown(); } else if(this.id == "secondpage") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/secondpage.php", hideLoading); content.slideDown(); } else { //hide loading bar if there is no selected section hideLoading(); } }); //show loading bar function showLoading(){ loading .css({visibility:"visible"}) .css({opacity:"1"}) .css({display:"block"}) ; } //hide loading bar function hideLoading(){ loading.fadeTo(1000, 0); }; }); Heres the structure of the menu/content Code: <ul id="menu"> <li><a id="home" class="normal" href="#Home"></a></li> <li><a id="secondpage" class="normal" href="#Secondpage"></a></li> </ul> <div id="content"> <ul id="sec-menu"> <li><a id="link1" class="normal" href="#">Link1</a></li> <li><a id="link2" class="normal" href="#">Link2</a></li> </ul> </div> Heres the code that jquery history plugin uses in demo for ajax Code: jQuery(document).ready(function($) { function load(num) { $('#content').load(num +".html"); } $.history.init(function(url) { load(url == "" ? "1" : url); }); $('#ajax-links a').live('click', function(e) { var url = $(this).attr('href'); url = url.replace(/^.*#/, ''); $.history.load(url); return false; }); }); I did something like this: Quote: $('#test').append("<option id='ddm'>added dropdown</option>"); it shows its html in the browser but I can't see it when I view source, is this normal? Thanks. Hi Friends, I am really tired with Chrome , one of my window.open() Stuff work fine in FF and Opera in Fedora O.S. But Chrome Did not , my code is like: <script type="text/javascript"> function getpage(id, type){ $.ajax({ type: "POST", data: "key="+id, async: false, url: "<?php echo site_url(); ?>/server/precp/"+type, success: function (msg) { window.open("<?php echo site_url(); ?>/server/cplogin/"+msg, "autologin"); } }); } </script> and it call in another JavaScript function like: function doKeyup(id,e) { if(e == 13) { //alert("e:"+e); var cp = $("table#serverdata tbody tr#container_tr.row_no td:nth-child(7) a#cp").html(); var dc = $("table#serverdata tbody tr#container_tr.row_no td:nth-child(7) a#dc").html(); if(cp != null || dc != null ) { var firstId = $("table#serverdata tbody tr#container_tr.row_no td:nth-child(1) input[type=checkbox]").val(); } if(cp != null) { alert("Enter here"); getpage(firstId,'cp'); return false; } and it firstly call from onkeyup as : <input type="text" name="find_text0" id="find_text0" autocomplete="off" <?php if ('B' == $sb_pos) { ?> onfocus="document.getElementById('find_text1').value='';" <?php } ?> onkeyup = "return doKeyup('0',event.keyCode);" /> Please Give me a Solution ASAP. Thankfully Anes I have a few tabs on my website. They're each set to the corresponding id in the JS file. It's supposed to add #tab-1 to the end of the URL in the users browser when it's clicked. For example, when a user is at mypage.com and they click on the tab, it ads mypage.com/#tab-1 to the end. How come it doesn't do what I want when I click it though? Here's an example of how it's setup. HTML: <a href="#tab-1" id="tab1">Text</a> JavaScript: document.getElementById("tab1").onclick = function(){ this.href += "#tab-1"; } This is a script which has a window slide down on the page and a user can choose yes/no to continue. It works in all browsers other than IE...any help please? If you need more info, please let me know. Thanks. <script language="JavaScript" type="text/javascript"> <!-- var allowpop=1; function popWin(){ var ppl="popLayer";var objppl=findObj(ppl); if (objppl==null){return;}// if the layer does not exist, do nothing. var args=arguments,movetoX=parseInt(args[0]),movetoY=parseInt(args[1]),movespeed=parseInt(args[2]); var cycle=10,pxl=""; if(!document.layers){objppl=objppl.style;} if(objppl.tmofn!=null){clearTimeout(objppl.tmofn);} var pplcoordX=parseInt(objppl.left),pplcoordY=parseInt(objppl.top); var xX=movetoX,yY=movetoY;if((pplcoordX!=movetoX)||(pplcoordY!=movetoY)){ var moveX=((movetoX-pplcoordX)/movespeed),moveY=((movetoY-pplcoordY)/movespeed); moveX=(moveX>0)?Math.ceil(moveX):Math.floor(moveX);movetoX=pplcoordX+moveX; moveY=(moveY>0)?Math.ceil(moveY):Math.floor(moveY);movetoY=pplcoordY+moveY; if((parseInt(navigator.appVersion)>4||navigator.userAgent.indexOf("MSIE")>-1) && (!window.opera)) {pxl="px";} if (moveX!=0){eval("objppl.left='" + movetoX + pxl + "'");} if (moveY != 0) {eval("objppl.top = '" + movetoY + pxl + "'");} var sFunction = "popWin(" + xX + "," + yY + "," + movespeed+ ")"; objppl.tmofn = setTimeout(sFunction,cycle); } } function findObj(theObj, theDoc){ var p, i, foundObj; if(!theDoc) theDoc = document; if((p = theObj.indexOf("?")) > 0 && parent.frames.length) {theDoc = parent.frames[theObj.substring(p+1)].document; theObj = theObj.substring(0,p);} if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj]; for (i=0; !foundObj && i < theDoc.forms.length; i++) foundObj = theDoc.forms[i][theObj]; for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) foundObj = findObj(theObj,theDoc.layers[i].document); if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj); return foundObj; } function hideLayer(layername){ layer=findObj(layername); if(layer.style){layer=layer.style;} layer.visibility='hidden'; } // --> </script> Hi! I'm new to JavaScript and I've done some small adjustments to my clients site, but it won't show properly in IE (the shadowbox js at least.). I thought js was accepted in all newer browsers. Do you have a quick fix or idea on why it doesn't work? You can view source on my site, I use mootools, and shadowbox/corners and rightclick blocker. Is it generally a 'bad thing' to use js in webpages I want everyone to view in the same way? I tried the same effects with CSS but it's not supported in the same way corss-browser, unfortunately. The 'no selection' CSS class I have on the site is also not accepted in IE. It's very annoying! http://santinacrolla.ihaarr.com/p thank you in advance! Below is code using the onmouseover event, but it doesn't work. The only thing that appears in the status bar is the URL. What am I doing wrong? Code: <a href="http://codingforums.com" onmouseover="window.status='This is an OnMouseOver event'; return true" onmouseout="window.status=' '; return true">Put your mouse here to see status info change at bottom.</a> Code: <html> <head> <script> function color() { var newColor=new Array('#00f','#f00','#ff0'); var i=0; for (i=0;i<=3;i++) { document.getElementByTagName(span).style.display=newColor[i]; } } color(); </script> <div> <span>make this text blue</span> <span>make this text red</span> <span>make this text yellow</span> </div> </body> </html> It should make the first blue, second red, and third yellow yes? hello... script doesn't work.. it does work in IE but not in another browser like mozilla,opera & safari? what should I do?.. Code: //Current HTML of page var html=""; //View of the page, Normal (Design), HTML, Preview var currentview=0; //Hold window objects for the color, table and properties dialogs var table_dialog, color_dialog, properties_dialog; //Current color action, ForeColor, or BackColor, //used for communication between PageCreate window and Color dialog window var pp; //Is used to disable use of design tools in HTML or Preview mode var enabletoolbar=false; //Variable counter used to index the search in the document var n=0; function InitEditor(){ //Init editor in design mode, maineditor.document.designMode=docmode; //Write a blank page WriteDefaultPage(); //Disable context menu maineditor.document.oncontextmenu=new Function("return false;"); //Set focus to the editor maineditor.focus(); } function EditorView(view){ //Changes editor view to Normal, HTML, and Preview if(currentview==1){ //If the last view was HTML then get the HTML edited by user in HTML mode html=maineditor.document.body.innerText; } //If the last mode was Normal then get the whole HTML content of the page else html=maineditor.document.all.tags("HTML")[0].outerHTML; if(view==0){ //Normal Mode EnableToolbar(true); maineditor.location="about:blank"; maineditor.document.designMode=docmode; maineditor.document.open("text/html"); maineditor.document.write(html); maineditor.document.close(); maineditor.document.oncontextmenu=new Function("return false;"); maineditor.focus(); } if(view==1){ //HTML Mode EnableToolbar(false); maineditor.location="about:blank"; maineditor.document.designMode=docmode; WriteDefaultPage(); HTMLView(); maineditor.document.oncontextmenu=new Function("return false;"); } if(view==2){ //Preview Mode EnableToolbar(false); maineditor.location="about:blank"; //Disable page editing maineditor.document.designMode="Inherit"; //Write the HTML of the page maineditor.document.open("text/html"); maineditor.document.write(html); maineditor.document.close(); //Enable context menu maineditor.document.oncontextmenu=new Function("return true;"); } //Set current view currentview=view; } function EnableToolbar(enable){ //Enable or disable toolbar enabletoolbar=enable; } function OpenFile(){ if(window.confirm("Do you want to save changes in the current document?")){ //Show Save As Dialog maineditor.document.execCommand("SaveAs"); } fileopen_dialog.style.visibility="visible"; } function OpenSelectedFile(){ //Check if the file is an HTML page if(document.fileselect.thefile.value.indexOf(".htm")==-1){ window.alert("The selected file is not an HTML page, please select a valid HTML file"); return; } //Hide the open file dialog fileopen_dialog.style.visibility="hidden"; //Create the FSO object var fso=new ActiveXObject("Scripting.FileSystemObject"); //Open the selected file var f=fso.OpenTextFile(document.fileselect.thefile.value); //Get the content of the file var thehtml=f.ReadAll(); //Close the file f.close(); //Write a blank page maineditor.window.location="about:blank"; //Write the HTML content maineditor.document.open("text/html"); maineditor.document.write(thehtml); maineditor.document.close(); //Set focus to editor maineditor.focus(); } function WriteDefaultPage(){ //Writes a blank HTML page in the editor var pagehtml="<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; " + "charset=windows-1252\">\n<meta name=\"GENERATOR\" content=\"PageCreate\">\n" + "<title>New Page</title>\n</head>\n<body>\n</body>\n</html>"; maineditor.document.open("text/html"); maineditor.document.write(pagehtml); maineditor.document.close(); } function NewPage(){ if(window.confirm("Do you want to save changes in the current document?")){ //Show Save As Dialog maineditor.document.execCommand("SaveAs"); } //Write a blank page maineditor.window.location="about:blank"; WriteDefaultPage(); //Set focus to editor maineditor.focus(); } function HTMLView(){ //Switch to HTML view maineditor.document.body.innerHTML=""; maineditor.document.body.innerText=html; } function TableOn(table, on){ //Highlights the table on which the mouse is over if(on) table.style.backgroundColor="#95AFFF"; else table.style.backgroundColor="#82DF82"; } function ToolbarOn(toolon){ //Highlights on or off the current toolbar //Get the toolbar button on which the mouse is over var tool=event.srcElement; //Change background color if(toolon){ tool.style.backgroundColor="#B4A0FE"; tool.style.borderColor="#000000"; } else{ tool.style.backgroundColor="#D1D1D1"; tool.style.borderColor="#D1D1D1"; } } function FindInPage(showdialog){ //Shows the Find and Replace Dialog var display="visible"; if(showdialog==false) display="hidden"; find_dialog.style.visibility=display; if(showdialog!=false) document.find.findwhat.focus(); } function FindIt(str, replacestr, newstr){ //This functions searchs for a string in the document //and if specified then replaces it with a new string if(str==""){ //If no string to search entered alert("Enter a string to search"); document.find.findwhat.focus(); return; } //Creates a range in the document txt = maineditor.document.body.createTextRange(); //Loop to find the string in the document for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart("character", 1); txt.moveEnd("textedit"); } if(found) { //If founded select it and scroll into view txt.moveStart("character", -1); txt.findText(str); //If replace is specified then replace the match with the new string if(replacestr) txt.text=newstr; txt.select(); txt.scrollIntoView(); n++; } else { if (n > 0) { window.alert("There are no more matches"); n=0; } // Not found anywhere, give message. else window.alert("\"" + str + "\" was not founded in document"); } } function InsertHTML(newhtml){ //Inserts HTML in the selection of the document maineditor.focus(); var selpoint=maineditor.document.selection.createRange(); selpoint.pasteHTML(newhtml); } function GetSelectedText(){ //Get the selection of the document maineditor.focus(); var selpoint=maineditor.document.selection.createRange(); var seltext=selpoint.text; return seltext; } function InsertNewImage(){ if(enabletoolbar==false) return; maineditor.focus(); //Open Insert Image Dialog maineditor.document.execCommand("insertimage", true, null); } function InsertForm(){ //Creates a new form var formmethod=window.prompt("Choose form method: GET | POST", "POST"); var formaction=window.prompt("Choose form action:", "http://"); InsertHTML("<div style=\"background-Color:#C0C0C0\"><form method=\"" + formmethod + "\" action=\"" + formaction + "\">\n<p> </p></form></div>"); } function InsertFormControl(control){ maineditor.focus(); //Inserts a form control maineditor.document.execCommand(control, true, null); } function CreateNewLink(){ //Inserts a link in the selected text if(enabletoolbar==false) return; var linktext=GetSelectedText(); if(linktext=="") return; var url=window.prompt("Enter a URL for the new link:", "http://"); if(url!=null){ InsertHTML("<a href=\"" + url + "\">" + linktext + "</a>"); } maineditor.focus(); } function InsertTable(){ //Open Table Dialog table_dialog=window.open("table.htm", "newtable", "top=100,left=100,height=300,width=400,scrollbars=no"); } function CreateTable(tr, tc, ta, tb, tp, ts, tw, tt){ //Creates a new table var tablewidth=""; if(tw!=""){ tablewidth=" width=\"" + tw + tt + "\""; } var thtml="<table border=\"" + tb + "\" cellpadding=\"" + tp + "\" cellspacing=\"" + ts + "\"" + tablewidth + ">"; tr=parseInt(tr); tc=parseInt(tc); for(r=0;r<tr;r++){ thtml+="<tr>"; for(c=0;c<tc;c++){ thtml+="<td></td>"; } thtml+="</tr>"; } thtml+="</table>"; InsertHTML(thtml); table_dialog.close(); } function EditPage(){ properties_dialog=window.open("properties.htm", "editpage", "top=100,left=100,height=275,width=387,scrollbars=no"); } function EditPageProperties(pt, pfc, pbgc, pbgi, usewatermark, pbgs){ maineditor.document.title=pt; maineditor.document.body.text=pfc; maineditor.document.body.bgColor=pbgc; maineditor.document.body.background=pbgi; if(usewatermark) maineditor.document.body.bgProperties="fixed"; else maineditor.document.body.bgProperties=""; if(pbgs!=""){ var pagehtml=maineditor.document.all.tags("HTML")[0].outerHTML; var bodytag= pagehtml.toLowerCase().indexOf("<body"); if(bodytag==-1) return; var beforebodytag= pagehtml.substring(0, bodytag); var afterbodytag= pagehtml.substring(bodytag, pagehtml.length); var pagehtml=beforebodytag + "<bgsound src=\"" + pbgs + "\">" + afterbodytag; maineditor.document.open("text/html"); maineditor.document.write(pagehtml); maineditor.document.close(); } properties_dialog.close(); maineditor.focus(); } function ChangeForeColor(){ //Show the Color dialog to edit Fore Color of text selected if(GetSelectedText()!=""){ pp="EditForeColor"; color_dialog=window.open("color.htm", "colorpicker", "top=100,left=100,height=270,width=500,scrollbars=no"); } } function EditForeColor(thecolor){ maineditor.focus(); //Change fore color of text selected maineditor.document.execCommand("forecolor", false, thecolor); //Close Color Dialog color_dialog.close(); } function ChangeBackColor(){ //Show the Color dialog to edit Back Color of text selected if(GetSelectedText()!=""){ pp="EditBackColor"; color_dialog=window.open("color.htm?p=EditBackColor", "colorpicker", "top=100,left=100,height=270,width=500,scrollbars=no"); } } function EditBackColor(thecolor){ maineditor.focus(); //Change back color of text selected maineditor.document.execCommand("backcolor", false, thecolor); //Close Color Dialog color_dialog.close(); } function ChangeFont(font){ //Changes the font of the selected text maineditor.focus(); maineditor.document.execCommand("fontname", false, font); } function ChangeFontSize(size){ //Changes the font size of the selected text maineditor.focus(); maineditor.document.execCommand("fontsize", false, size); } function DesignTools(tool){ //Activates design tool if(enabletoolbar==false){ window.alert("You must switch into normal view to do this"); return; } maineditor.focus(); maineditor.document.execCommand(tool, true, null); } Hi! What am doing wrong? The script works -- identifies blank fields -- but the second function (change_subject) is ignored. This is the script: Code: <HEAD> <script> function is_filled() { if (form_1.realname.value=="") { alert("Please enter your name") form_1.realname.focus() return false } if (form_1.subject.value=="") { alert("Please enter a subject") form_1.message.focus() return false } else return true }; function change_subject { form_1.subject.value="form_1.realname.value + '_' + form_1.subject.value" }; </script> </HEAD> This is the FORM (used for MSA FormMail): Code: <form name="form_1"; onSubmit="return is_filled()"; on Submit="change_subject()"; method="post"; action="http://gb2gf.org/cgi-sys/FormMail.cgi"> <input type="hidden" name="recipient" value="drt@gb2gf.org"> <input type="hidden" name="required" value="greeting,realname,city_state,email_1,email_2,message"> <input type="hidden" name="sort" value="order:greeting,realname,city_state,email_1,email_2,message"> <input type="hidden" name="redirect" value="http://www.gb2gf.org/thanks.htm"> <!-- Input fields here --> </form> Thanks! Dr. T. Heya, I wrote the following page in a day or two (please don't mind the layout). Everything seems to work excellent, apart from in Firefox (FF) in which it doesn't seem to work at all. None of the other browsers have any trouble with it. I'm pretty new to Javascript (everything you see in the source code is pretty much all I know) and I have absolutely no idea why it doesn't work in Firefox. The page in question could be found [link has been removed]. It's all there is to it. So yeah, how to actually make this work in FF? Thanks a whole bunch in advance! Much appreciated. I've got a form textarea on my site, which after being submitted is stripped by my php file. Then my javascript kicks in and does some analysis of the entered text. However everytime the user entered a hard return within the textarea my javascript gives me an error 'tekenreeks niet afgesloten' which means something like 'string is not closed'. Therefore I decided to replace all occurences of chr(10) and chr(13) with ok2 (just some random characters), I did this with php which worked fine, and I didn't get the javascript error. However I need to reshow the entered text (original) to the user, so I need to restore the old values. I tried Code: result.waarde.replace('ok2', 'chr(13)'); but it doesn't work, as it still displays ok2. I'm no expert in javascript, but how can I replace those characters by the hard returns? Oh yeah I'll show some more coding, perhaps the error can be found the Code: result.waarde.replace('mdw', 'chr(13)');container.innerHTML = result.waarde; and in my html: Code: <div id='waarde' style="width:500px;"></div> Hello. I have a youtube video that autoplays everytime one opens the webpage containing the video. The only extra parameter that causes the video to autoplay is having the following added at the end of the embed src link: "&autoplay=1" If that is not present or if a zero is present in place of the 1, the video does not autoplay. I would like the video to play only once per session. If one is visiting the webpage a second time, the parameter above should not be present or the 1 should be a zero. I am modifying attempting to modify this code: http://www.javascriptkit.com/script/...2/postit.shtml and I am able to get differnt urls to print on screen depending if it's a first visit or not. Problem 1: I cannot however get this to work in Google Chrome. Problem 2: When I attempt to get the url to be printed inside the embed src [/B]link, which is inside the object tag, the javascript either gets printed or that portion is ignored. I don't know if this is because of the quotations and the way I am handling them or if because javascript cannot be inserted inside an object tag. Here is the code: Code: <html> <body> <br><br> <script type="text/javascript"> //Post-it only once per browser session? (0=no, 1=yes) //Specifying 0 will cause postit to display every time page is loaded var once_per_browser=1 ///No need to edit beyond here/// /* var ns4=document.layers var ie4=document.all var ns6=document.getElementById&&!document.all if (ns4) crossobj=document.layers.postit else if (ie4||ns6) crossobj=ns6? document.getElementById("postit") : document.all.postit function closeit(){ if (ie4||ns6) crossobj.style.visibility="hidden" else if (ns4) crossobj.visibility="hide" } */ var url = "\"http://www.youtube.com/blah/version=3&hl=en_US&fs=1\""; function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) if (offset != -1) { // if cookie exists offset += search.length // set index of beginning of value end = document.cookie.indexOf(";", offset); // set index of end of cookie value if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; } function showornot(){ if (get_cookie('postdisplay')==''){ showit() document.cookie="postdisplay=yes" } } function showit(){ url = "\"http://www.youtube.com/blah/version=3&hl=en_US&fs=1&autoplay=1\""; /*if (ie4||ns6) crossobj.style.visibility="visible" else if (ns4) crossobj.visibility="show" */ } if (once_per_browser) showornot() else showit() </script> <b>Outside the Object Tag:</b> <br> <script type="text/javascript">document.write(url);</script> <br><br> <b>In the Object Tag</b> <br><br> <object width="570" height="250"><param name="movie" value="http://www.youtube.com/blah?version=3&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src=<script type="text/javascript">document.write(url);</script> type="application/x-shockwave-flash" width="570" height="250" allowscriptaccess="always" allowfullscreen="true"></embed></object> </body> </html> |