I've created a simple placeHolder for some extra javascript in jQuery - The issue is that the placeHolder is within some script tags and therefore isn't recognized by Sharepoint designer.
The page works correctly, so it hasn't bothered me until now, since you can't touch any part of the design view, without fixing the issue.
My code looks something like this in the master template:
<script type="text/javascript>
$(document).ready(function(){
<asp:ContentPlaceHolder id="PlaceHolderjQuery" runat="server" />
});
</script>
Is there a way to make this work correctly, so that the placeholder is actually recognized by Sharepoint Designer?
Thanks for the help!
I understood that you are trying to call a JavaScript function that is defined inside the PlaceHolder.
But your code wont work as the PlaceHolder is a Server Control and pushing it as a child element of the some other tag wont work. Script tag is a client processing tag. So What I would suggest is to change the logic as below.
In the master page I will have a JavaScript to call a function by default.
<script type="text/javascript>
$(document).ready(function(){
myOnLoadFunction();
});
</script>
And I will define the content Place Holder with a dummy function
<asp:ContentPlaceHolder id="PlaceHolderjQuery" runat="server">
<script type="text/javascript>function myOnLoadFunction(){ //do nothing }</script>
</asp:ContentPlaceHolder>
Now in your content page you can define
<asp:Content ID="javascript" ContentPlaceHolderID="PlaceHolderjQuery" runat="server">
<script type="text/javascript>function myOnLoadFunction(){ alert('Hello jQuery'); }</script>
</asp:Content>
Related
How can I scroll to a certain anchor tag inside the IFrame page?
Using the ingenious Iframe-Resizier Library by David J. Bradshaw
https://github.com/davidjbradshaw/iframe-resizer
I’m including an IFrame with a lot of content (=long page) inside the outer page. So if I link to the page, then much of the content isn't visible on the first screen and under certain circumstances I would like to jump to a specific anchor tag further down in the iframe.
<html>
<a href=“outer-page.html#somewhere_name” />
</html>
seems not to work
I am using "inPageLinks: true" like this:
<script type="text/javascript">
iFrameResize({
heightCalculationMethod: 'lowestElement',
inPageLinks: true
</script>
My question now is: How can I make the outer page scroll down to a certain anchor tag without the need to implement something new inside the iframe page? The anchor tag in this case is located inside the IFrame page.
When I include the IFrame page like
<html>
<iframe id=“strytl” src=“iframe-page.html#somewhere_name”></iframe
</html>
Then the (re)sizing of the IFrame seems not to work perfectly and contents at the top of the iframe are getting cut off.
But with moveToAnchor it works perfectly from inside the IFrame and the page is magically scrolling down to the anchor tag. So in the iframe page I can call:
<script type="text/javascript>
parentIFrame.moveToAnchor('somewhere_name’);
</script>
But how can I trigger this from the parent page?
<script type="text/javascript>
$('iframe#strytl').iFrameResize({moveToAnchor: 'somwhere_name'});
</script>
results in this error:
<script type=“text/javascript”>
[iFrameSizer][Host page: strytl] Ignored iFrame, already setup.and
</script>
And
<script type="text/javascript">
iFrameResize({
heightCalculationMethod: 'lowestElement',
inPageLinks: true,
moveToAnchor: 'somewhere_name'});
</script>
seems to have no effect at all.
(In this case the outer page and the iframe have different server names.)
<script type=“text/javascript”>
var myFrm = document.getElementById('strytl');
var myCw = myFrm.contentWindow;
myCw.parentIFrame.moveToAnchor(‘somewhere_name’);
</script>
result:
<script type=“text/javascript”>
Error: Permission denied to access property “parentIFrame"
</script>
Can I jump to an anchor in the iframe from the outer page at all?
Something like this.
<script type="text/javascript">
iFrameResize({
heightCalculationMethod : 'lowestElement',
inPageLinks : true,
initCallback : function (iFrame){
iFrame.iFrameResizer.moveToAnchor('someAnchor');
}
});
</script>
I can't find any way to get rid of the call to action button on my landing page layout in Weebly. Is it possible to get rid of this button?
You need to perform two steps.
Remove the button from the desktop layout.
Open the layout file in HTML edit mode.
Remove the following line:
<div class="button-wrap">{action:button global="false"}</div>
Remove the button from the mobile layout.
Add the following script to the Header Code of the page:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script language='javascript'>
$(document).ready(function(){
$('.landing-container').remove();
});
</script>
You can see it in action on this site for gluten free products.
Has anyone gotten the current version of fancybox 2.1.4 (http://fancyapps.com/fancybox/) with jQuery 1.9.1 to work with Microsoft Office SharePoint Server (MOSS) 2007?
Seems like the out of box css/html of MOSS 2007 is interfering with the sizing and positioning calculations that fancybox/jQuery does. The end result is a tiny fancybox (130px width).
Here is a screenshot of the issue:
screenshot of issue http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-54-79-Images/4152.fancyboxIssueInMOSS2007.png
Here is the super simple code I am doing:
MAIN PAGE:
<%# Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
<link type="text/css" rel="stylesheet" href="jquery.fancybox-2.1.4_Styles.css" />
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript" src="jquery.fancybox-2.1.4.js"></script>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
Hello from the test page!
<a id="fancyBox1" style="display: none" data-fancybox-type="iframe" href="iframeContents.aspx"></a>
<script type="text/javascript">
$(document).ready(function () {
// show fancyBox
$('#fancyBox1').fancybox().trigger('click');
});
</script>
</asp:Content>
IFRAME PAGE:
<%# Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
Hello from the iframeContents!
</asp:Content>
Thanks for any and all help!
PS-By the way, fancybox works fine in SharePoint 2010. However, I must make it work in MOSS 2007.
SOLVED!!! Thanks JFK.
Yes, the problem was the browser (IE 10 in this case) was running in quirks mode since there was no DOCTYPE present. After I added the DOCTYPE to the master page, fancybox works!
<!DOCTYPE html>
Side note: having the DOCTYPE added to the masterpage actually disrupts out of box MOSS 2007 branding. But it's ok in my case since we will be using custom branding that already does have the DOCTYPE present. I got lucky with that one. Thanks again for the help!
I have an extension which adds a bar at the top of a webpage. i have inserted the iframe in the content script using
document.body.insertBefore(iframe, document.body.firstChild);
The iframe has a button
<button id="mybutton">Click to help</button>
When the user clicks the button I want to redirect them to a new url in the same window. Is this possible?
The reason I want to do this is on certain websites I would like to change the url to include an additional parameter. I chose the iframe option as it more visible than an extension in the bar. Therefore if there is an alternative way to do this I would be happy to learn about it.
Your iframe.....
<html>
<head>
</head>
<script type="text/javascript">
function changeParent(e){
parent.location="http://google.com.au";
}
function onLoad(){
document.querySelector("#mybutton").onclick = changeParent;
}
</script>
<body onload="onLoad()">
<a id="mybutton">Change Parents URL</a>
</body>
</html>
Would be a good case for info bars if they ever come out of experimental....
http://code.google.com/chrome/extensions/experimental.infobars.html
We're trying to use the built in SharePoint spell check functionality but unfortunately it seems that it doesn't allow anonymous users to access the page. I'm calling the spell via the normal JS call:
<SharePoint:ScriptLink ID="ScriptLink1" Language="javascript" Name="core.js" runat="server" />
<SharePoint:ScriptLink ID="ScriptLink2" Language="javascript" Name="bform.js" runat="server" />
<SharePoint:ScriptLink ID="ScriptLink3" Language="javascript" Name="SpellCheckEntirePage.js" runat="server" />
<script language="javascript" type="text/javascript">
function SpellCheck() {
SpellCheckEntirePage('/_vti_bin/SpellCheck.asmx', '/_layouts/SpellChecker.aspx');
}
</script>
Basically it seems that the /_layouts/SpellChecker.aspx page is the issue. I made a copy of the file and moved it to the pages library and referenced it there and it fixed the issue for that page but then it was requiring login for the master page that page uses and some controls. Short of attempting to locate and copy out each referenced page (which I'm not convinced will even work in the first place) I'm not sure what will fix the overall issue.
Am I missing something here or is it just going to not work?