HTML Fragment

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/11/2011 3:58:30 PM
Gravatar
Total Posts 12

HTML Fragment

Hi

I am trying to include a UK Ordnance Survey mapping system (www.ordnancesurvey.co.uk/oswebsite/web-services/os-openspace/api/index.html) into my web site (www.stevensonway.org.uk) and am having some problems. The OS web site creates suitable code but it includes a <head> and a <body> plus various <script> blocks. I can drop the <head> from the code but really need to include the <body> section in the main page <body>.

This is what needs to be in the <head>

onload="initmapbuilder()"

and in the <body>

<div id="map" style="border: 1px solid black; width:800px; height:600px;"></div>

So do you have any suggestions as to how I can accomplish this?

The alternative might be to use an iFrame but then I am not sure where to put the code so that it can be referenced.

You can see the source code here: www.stevensonway.org.uk/the-way.aspx It shows all the code as produced by the OS application before any mods are done.

Many thanks

Ian Logan

6/12/2011 1:30:35 PM
Gravatar
Total Posts 18439

Re: HTML Fragment

Hi Ian,

You can probably add the stuff for the head directly in the head in the layout.master file of your skin. I assume its just script files and maybe css. You will need to use urls for the script and css that are fully relative to the root of the site like /yourscripts/yourscript.js

ie that would work if the script is in a folder beneath the root named "yourscripts", the first / represents the root of the site.

If the map is supposed to be on every page you could put that div also in layout.master somewhere.

If you want it just on a specific page then you could add an instance of the Html Content feature to a page and in source view of the editor you could paste in the div.

Rather than set the onload on the body element you could wire it up from jQuery like this

<script type="text/javascript">

        $(document).ready(function() {
           initmapbuilder();
        });
</script>

This should be equivalent to body onload, it will fire the script function after the page is loaded.

The script should go wherever you put the div, ie if in the Html you can paste it also there or in layout.master if that is where you put the div.

Hope that helps,

Joe

6/13/2011 3:52:26 PM
Gravatar
Total Posts 12

Re: HTML Fragment

Joe

Many thanks for responding. I got a similar answer on the Ordnance Survey forum where someone suggested using:

$(document).ready(initmapbuilder);

immediately before the function initmapbuilder() in your last <script> block.

So I can keep it simple and just use an HTML Fragment rather than messing around "under the hood" - much easier to maintain!

Kind Regards

Ian

 

8/24/2011 3:22:50 PM
Gravatar
Total Posts 245
mojoPortal Community Expert

Re: HTML Fragment

Cool.  Thanks for that Joe.  It works perfect replacing <body onLoad="init2()">

Needed this to get HTML5 canvas drawing to work in my newest mojoPortal feature.

I put it in my features C# script like this:

StringBuilder script = new StringBuilder();
script.Append("\n<script type=\"text/javascript\">");
script.Append("$(document).ready(function(){");
script.Append("init2(); ");
script.Append("}); ");
script.Append("</script>\n");

this.Page.ClientScript.RegisterStartupScript(
   this.GetType(),
   this.UniqueID,
   script.ToString());

Rick Hubka

You must sign in to post in the forums. This thread is closed to new posts.