none
Expression Web 4 and Javascript

    Question

  • Hi all, this is a Newbie Expression Web question but not a newbie JS question.  I created a site that I had been working on in Visual Studio because I wanted to try Expression Web. I use JavaScript with the site but cannot seem to add my JavaScript files to my newly created Expression Web Site. 

    How do I add my JavaScript to my site?


    Thanks, -ja

    Monday, August 19, 2013 3:18 AM

Answers

  • I usually just create a "scripts" folder in the root directory, put the scripts there, then reference them as usual in the <head> section of the page. For example, from the head section of one of my sites:

    <script type="text/javascript" src="scripts/swfobject.js"></script>
    <script type="text/javascript">
    	swfobject.embedSWF("HeaderTrans.swf", "headerFlash", "450", "160", "9.0.0", "expressInstall.swf", {}, {wmode:"transparent"},{});
    </script>
    <script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="scripts/jquery.innerfade.js"></script>

    These days, there are a great many CDNs (Content Delivery Networks) that will serve common libraries (jQuery, Prototype, Mootools, etc.), if you prefer not to host them on your own site.

    If you want to embed a script in the body (very obtrusive, but it can be done), simply create a script element wherever you want to implement it, like this:

    <script type="text/javascript">
        $(document).ready(
            function(){
                $('#testList').innerfade({
                    speed: 'slow',
                    timeout: 4000,
                    type: 'sequence',
                    containerheight: '220px'
                });
            }
        );
    </script>

    That's jQuery, but it's typical of a script element.

    If you have used javascript before, I'm surprised that you have to ask this. How have you done it before that was different than this?

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Monday, August 19, 2013 3:41 AM

All replies

  • I usually just create a "scripts" folder in the root directory, put the scripts there, then reference them as usual in the <head> section of the page. For example, from the head section of one of my sites:

    <script type="text/javascript" src="scripts/swfobject.js"></script>
    <script type="text/javascript">
    	swfobject.embedSWF("HeaderTrans.swf", "headerFlash", "450", "160", "9.0.0", "expressInstall.swf", {}, {wmode:"transparent"},{});
    </script>
    <script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="scripts/jquery.innerfade.js"></script>

    These days, there are a great many CDNs (Content Delivery Networks) that will serve common libraries (jQuery, Prototype, Mootools, etc.), if you prefer not to host them on your own site.

    If you want to embed a script in the body (very obtrusive, but it can be done), simply create a script element wherever you want to implement it, like this:

    <script type="text/javascript">
        $(document).ready(
            function(){
                $('#testList').innerfade({
                    speed: 'slow',
                    timeout: 4000,
                    type: 'sequence',
                    containerheight: '220px'
                });
            }
        );
    </script>

    That's jQuery, but it's typical of a script element.

    If you have used javascript before, I'm surprised that you have to ask this. How have you done it before that was different than this?

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Monday, August 19, 2013 3:41 AM
  • There is nothing different about EW vs Visual Studio as far adding javascript files to your site.  You simply ... put them in your site, as you would any other file.  You can create them in EW, import them with EW if you have created them elsewhere, or move them there using normal Windows operations. (Be sure to refresh the File panel view if you do it outside of EW, so EW will see them.)

    (Did your question have some other meaning?)

    Monday, August 19, 2013 6:38 AM