Logo 
Search:

Sharepoint 2010 Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint 2010       RSS Feeds

jscript+jQuery won't run

  Date: Feb 20    Category: Sharepoint 2010    Views: 1553

What am I doing wrong?

I put up VERY simple jQuery lib & script onto SP2007 using SPD, and it ran the
first time using XP and IE7.

Now I am using SP2010, OOB, no Designer, and Win 7 + IE9. I tried
1) pasting code below into CEWP in a WPP in a DocLib
2) pasting code below into "site Pages" library new page

In both cases, all I got back was the text below that I pasted in.
My goof has to be simple. At least I expected an error msg regarding the jQ
library.
=================


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery demo</title>
</head>
<body>
<a href="http://jquery.com/ ">jQuery</a>
<script src="
ajax.googleapis.com/.../jquery.min.js"></script>
<script>
$(document).ready(function(){
$("a").click(function(event){
alert("As you can see, the link no longer took you to jquery.com");
event.preventDefault();
});
});
</script>
</body>
</html>

Share: 

 

4 Answers Found

 
Answer #1    Answered On: Feb 20    

Put the code in a text file, and have the CQWP include the text file.

 
Answer #2    Answered On: Feb 20    

Is the script checked in? The site pages library has documents checked out by
default.

 
Answer #3    Answered On: Feb 20    

I will look at the chk/in/out status on Monday at the office.
Deanna: I don't understand what putting the code into a "text" file has to do
with it. CEWPs don't typically take files, just typed in content, pasted in
images, or URLs to pages(files). In any case, I never needed to do this in
SP2007.

 
Answer #4    Answered On: Feb 20    

In 2010, CQWP DO take text files. And, for security, it strips out JS
(sometimes, inconsistently it seems) pasted in as html.

Add a CQWP.
Click "Edit WebPart"
Put a link to the text file in the content link box.
Don't put anything in the CQWP itself at all. (It only pays attention to
either the content link OR the content in the web part.)

 
Didn't find what you were looking for? Find more on jscript+jQuery won't run Or get search suggestion and latest updates.




Tagged: