SharePoint 2007 javascript alerts do not display
-
Saturday, May 05, 2012 1:03 PM
By placing a javascript txt file in a CEWP, how can I make the script execute.
I have a small script that just displays an alert. The alert does not display which tells me that placing a script in a CEWP is not enough. There must be some other code required to execute the script.
It works in SP 2010 but not in WSS3.
Tried using _spBodyOnLoadFunctionNames.push("show_alert"), that doesn't work either. Must be a 2010 thing.One additional point... If I "view source", the script IS there.
- Edited by jd_hancock Saturday, May 05, 2012 1:16 PM
All Replies
-
Sunday, May 06, 2012 9:56 AMHave you checked if you have any JavaScript errors that might prevent your script from running? Another option is to debug your script using IE, VS or Firebug and to see if your script is executed.
w: http://blog.mastykarz.nl | t: @waldekm | c: http://mavention.codeplex.com | c: http://mavention.nl
-
Monday, May 07, 2012 2:11 AM
Hi jd_hancock
It should works when you just write a script in the CEWP like this:
<script type="text/javascript"> alert('wt'); </script>
There must be some errors on your web page, the script will stop executing when some exceptions are thrown. You should fix these errors first. Sometimes the scripts SharePoint provided will also contain some errors, such as ActiveX control not installed. You can turn on the script debugging to find out the reason by clicking Internet Options->Advanced->Settings->Browsing, uncheck Disable script debugging(IE). You can also debug the page by using IE. Please use IE to debug the errors, some error can only reproduced by IE with SharePoint 2007.
You can also put the CEWP at the top of the page so that the alert can popup before some exceptions thrown in the middle part of the page.
Thanks,
Lambda Zhao
TechNet Community Support
- Edited by Lambda Zhao Monday, May 07, 2012 3:13 AM
-
Monday, May 07, 2012 10:39 AM
Thank you both. Tried Firebug but the code was not executed. Set a breakbpoint but it's not stopping. No errors showed up in the status bar in IE however the IE9 status bar is not working that I can see. It never displays a "done" message or the progress bar.
The alert is just as you have it Lambda.
Thanks again.
-
Monday, May 07, 2012 10:40 AMI probably need to test the page on an older IE version to see if there are any errors on the page since IE 9 is not ready yet.
I'll see if I can get a working version of IE to test it on. -
Monday, May 07, 2012 11:08 PM
The IE9 developer tools don't work so I can't step thru the code. You can set breakpoints but the step options are inactive. Whenever page is refreshed, all breakpoints are deleted. I have script debugging enabled but no script errors display. Another IE9 bug.
Firebug cannot step into code either. Icons are visible but inactive.
If I could remove IE9 and go back to IE8 or a working version of IE, I could probably find the problem.
I will let my users know it's an IE issue.
Thanks everyone for the assistance.
- Edited by jd_hancock Monday, May 07, 2012 11:10 PM
- Marked As Answer by jd_hancock Tuesday, May 08, 2012 10:26 AM
-
Tuesday, May 08, 2012 6:06 AM
jd,
I hope you have verified that the browser settings is enabled for running Javascripts (or Active scripts in case of IE). Without this, enabling script debugging may not be of help.
Thanks Arut
-
Tuesday, May 08, 2012 10:26 AM
I use many scripts in many applications. VS 2010 debugging works fine and basic javascript client code works fine as well.
It's just a debugger issue with Firefox and debugger issue with IE9 (and script error notification). The fact that SP2007 does not run scripts is something I can tell my users I will not be able to provide the solution they are seeking.(for now). I will need to see if i can get a IE7 machine to find the problem. It threw errors and notified me of the line causing the error.
Thank you for the thought.
- Edited by jd_hancock Tuesday, May 08, 2012 10:30 AM
-
Tuesday, June 05, 2012 3:29 PM
I have found this same problem. It is not just an IE thing, the javascript does not run in Chrome or Firefox either. I'm also using IE8, does not run.
What I have discovered is that it appears to be something related to security and DNS zones. The javascript does not work on our Corp wss 3.0 site which runs in Trusted Site zone. But our local wss 3.0 install, which runs in intranet zone, the javascript runs just fine. It has nothing to do with local browser settings, I have verified there is no setting blocking javascript.
I am stumped right now. I have been searching forums on this subject but no one seems to have even figured out as much as I have, most likely because they don't have sites in 2 different DNS zones to test with.
Anyone who has any insight on this I would sure appreciate a comment. Nothing trick about the javascript, just an alert box saying you will be redirected to new URL.
terry bridges
-
Tuesday, June 05, 2012 4:38 PMI found my problem, I was way off track. The javascript I copied in from internet had extra single quotes in the script tag, essentially turned entire block into a comment. No wonder wasn't running. Duh.
terry bridges

