Im using Javascript to expand a unordered list menu and it works on my pc in the latest versions of Opera, Safari, Firefox and IE. But i have been told that the buttons do not work in Safari on a MAC. It does however work in IE on a MAC.
Is there a difference between the way Safari on a MAC would read the code? Code:
I am just finishing a site for a photographer which uses Flash for the interface, PHP to display a number of image thumbnails (4 scripts, depending on the route the visitor has chosen) and then 1 PHP page with lots of JavaScript to open the correct image in a new popup window.
It all works in the latest versions of NN & IE but the problem is that some of the site owners' clients use older browsers and the JavaScript popups are not working in NN 4.7.
The address of the developing site is here. The JavaScript that I am using is an adaptation of Anarchos' great script.
Are there fundamental things I am missing regarding NN 4.7 and JavaScript or would my scripting in JavaScript be wrong?
I have a Javascript redirect on pages inside my site (not the index page) because Netscape 4+ doesn't see the CSS properly. I'd tested it at home, and it worked fine. But now testing it on another computer, its not redirecting. Code:
Can anyone recommend a good place for someone like myself to start learning about JavaScript and Java Applets? I know HTML, CSS, and a decent amount of Perl and PHP, but overall have VERY little experience with Java and JavaScripts, other than the usual cut-and-paste...
I am using Regular Expressions and Javascript to validate a form, specifically I want to make sure that if they try to upload a file that it has a proper name w/ certain extensions (doc,pdf, rtf). The script works on IE and Mozilla but fails on Safari on the MacOSX. Here is my code..
// ok files with proper extension var reOKFiles = /^([a-zA-Z].*|[1-9].*).(doc|DOC|pdf|PDF|rtf|RTF)$/;
//where i check for the file... if(window.document.myForm.myDocument.value != ""){ var fileStr = window.document.myForm.myDocument.value; if(!reOKFiles.test(fileStr)){ alert("Please try again, you tried to upload an invalid file type for CRITERIA 1"); window.document.myForm.myDocument.focus(); return (false);
function showMenu() { for(i = 0; i < max; i++) { setTimeout("document.getElementById('contextlinks').getElementsByTagName('UL')[0].style.filter = 'alpha(opacity="+i+")'",100); } }
This is supposed to increment the alpha opacity of the UL inside the DIV contextlinks by 1% every 0.1 seconds (for a fade effect). However when the function is activated, the opacity is set directly to 100% rather than increasing bit by bit.
Looks fine in IE and Opera, but is designed to write into a textarea instead of the <div> if the brower is not IE4+ (why is it working in Opera?) so on Firefox you can see the ugly textarea....
Is there a way to either turn off the Javascript in Firefox so it doesn't work at all, or test specifically for that browser (it's not testing for anything but IE right now as I understand it) and put the text into an absolutely positioned element? Code:
I stumbled upon a strange behaviour of the XMLHttpRequest.. Maybe I'm just not well informed enough about its possibilities, so could someone please confirm my question?
When I put plain javscript in a file that is read-in through a XMLHttpRequest-object, it's like it is totally ignored. Eg. I have the file ajax_include.html with in it's body the following lines <script type="text/javascript" language="javascript"> alert('some alert'); </script>
when I directly surf to the file, the alert pops up as expected, but when I use a simple XMLHttpRequest to replace the contents of a div with the contents of this page, the alert is not popping up, although when I view the selection's source (Thank you, Firefox!), it is there!
When I place an anchor with an onclick-action (eg. alert('onclick')), it works when I click it. So my "conclusion" is that it seems like inline javascript commands are ignored (functions not recognized etc.). All actions assigned to other events work nice though.
Can someone confirm this strange behaviour? Or is it just normal with the use of an XMLHttpRequest opbject?
This code works to insert a MySQL record to a Database using AJAX. It works fine on IE, but it's not working on FF or Chrome. When I test it on FF/Chrome, i just get the text "Just a second..." and it doesn't advance from there.
I'm working on some code and am running into brick walls. I'm trying to write out Javascript with Javascript and I've read the clj Meta FAQ and didn't see the answer, read many similar posts (with no luck though), and searched through the IRT.ORG Faqs (www.irt.org/script/script.htm).
The Javascript is designed to open an popup window and then inside that window call another script which will resize that window. There may be another way around this but the reason I tried this approach initially was that I wanted to call the onload handler in the popup window to resize the image only after the image had completely loaded. I've had some code in the primary Javascript file (showimage.js) before that works if the image has been cached but on the first load, it doesn't resize properly which tells me it is probably because it is trying to resize the window based on the image size but it isn't completely known at that point. So I removed that code and tried placing the resizing code in the second Javascript file (resizewindow.js). BTW I've tried other code to open a popup image and automatically size it ie Q1443 at irt.org but that doesn't do exactly what we need.
Even if there is another way to do this with one file, I still want to figure out why this isn't working in case I run into it in the future.
I thought what I would need to do to use document.writeln to write Javascript would be to escape any special characters and to break apart the script tag ie
document.writeln('</SCRIPT>');
would become
document.writeln('</SCR' + 'IPT>');
I have a HTML page and 2 Javascript files. All files are in the same directory and have permissions set correctly.
Here are the 3 files (keep in mind wordwrap has jacked up the formatting):
index.html ---------- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test</title> <SCRIPT type="text/javascript" LANGUAGE="JavaScript1.1" SRC="showimage.js"> </SCRIPT> </head>
<body> Click the house<BR> <A ONCLICK="newWindow1('house1.jpg','Nice House')"><IMG SRC="house1thumb.jpg"></A> </body> </html>
showimage.js ------------ function newWindow1(pic,sitename) {
resizewindow.js --------------- function resizewindow() { // Do resizing here. // Right now this isn't being executed alert("resizing window"); }
Can anyone provide some pointers as to why this javascript is failing? I'm using IE6 on Win2k and when I click on the image to open the popup window, it does open the window but it is white with no content and the system immediately goes from about 4% CPU usage to 100% and consistently stays there until I kill that window with the task manager.
I am working on a Javascript application and i am facing a strange behavior of the application in IE. I am creating a table at runtime using DHTML and registering event for the table row click. When i deploy this application on web server and browse the application, the events fires in firefox and chrome but in IE the events are not fired. If i browse the application from the server with localhost, the application triggers the events and fails when i use machine name.
The following is the source code:
<!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> <title></title>
Attached is a simple HTML file that adds and delete rows. In the add row function I set an attribute "onClick" this triggers the testMessage() function. When I try this in Firefox it works just fine however on IE it just refuses to work.
What is interseting is the ROW that already exists has a similar 'onClick' event which works when the page is loaded, but subsequent "row" additions to the table to not work in IE. Code:
I'm getting errors in Firefox everytime I try to run this frame resize code, but it works fine in IE. I can't seem to figure out what the problem is with it.
The error is: Error: theFrame has no properties Line: 8
The line that the javascript console is showing an error for is in italics.
I'm already past the basics of Javascript, and i need something that takes me to the other level and teaches me the new technologies and cool stuff (drag&drop, AJAX, OOP in javascript, maybe XUL...etc). So far i found these two books:
1. Sitepoint's "The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks". 2. Worx's "Professional JavaScript for Web Developers (Wrox Professional Guides)"
Both seems to cover very insteresting topics, but i can only buy one of them. So which one do you suggest?
and by the way, i've read the sample chapter 5 of Sitepoint's book, and it seems like the author(s) just put the solutions/codes there and let you figure them out on your own. Is this how the rest of the chapters are?
I am trying to create 3 boxes with 2nd select box content to be uploaded on the basis of value selected in first box and third box list should be uploaded on the basis of value selected in 2nd box.i have written coding for that as below but it is not working .
This is a question about defensive web browsing. Ocassionally I run into a page whose JavaScript does something that I find obnoxious. I would like to turn off JavaScript only for that page (instead of disabling it globally). It would be cool if there were some way to do this through a "bookmarkable" JavaScript snippet using the javascript: pseudoprotocol. Does anyone know any trick to do any of this?
I am looking for a method to extract the links embedded within the Javascript in a web page: an ActiveX component, or example code in C++/Pascal/etc. I am looking for a general solution, not one tailored to a particular page/script.
Hopefully, the problem can be solved without recreating a complete Javascript interpreter. Any ideas?
I have some javascript that I have written into the <body> section and it works great. But I would like to make it into a javascript function and define the function in the <head> section. Then in the <body> section write a small bit of javascript that would call the function() object. Code:
I would like to know how to write javascript such that, a part of it isnt considered as script, & rather as HTML. Code:
Ok, the layer div can be written using document.write. But, Google ad itself is a javascript isnt it. How can it be written into this? How does this work?
Ok so, this is my purpose: - to be able to load asynchronously (via AJAX) some javascript ads (like google's or adbrite) so as to make them be loaded in the background, then update the page after the ads have loaded via innerHTML
Why? -Because 90% of the time in my newer sites, javascript ads are the major offender in terms of speed of page rendering
My problem: Via ajax, I can call a php file that retrieves some javascript and outputs it, XMLhttprequest returns those javascript lines, but they don't render in the page, since they miss the whole page loading, and are apparently not parsed For example, let's say I call a php file via ajax, and it returns the output into a variable named "text" containing "document.write('hello')" if I use xxx.innerHTML=text, nothing happens
My 1st solution: Passing those javascript lines to eval() [like eval(text) ], but this produces a second problem, that I couldn't solve (probably because of my lack of knowledge in javascipt): if I eval the code, it deletes my current page and renders a new one for example, if I parse a document.write, my page disappears, and a new one is rendered with the document.write text
What I want is basically to make that "document.write" appear inside a div in my page, adding to the content (and not overwriting the whole page), much like what happens when using innerHTML
Is this even possible? How would you go about it? I tried xxx.innerHTML=eval(outputfromphpfile) but it overwrites my whole page...