to create a js

Discussion in 'JavaScript' started by jonhyhar, Nov 14, 2009.

  1. #1
    hi there,

    How can i change a code that looks like this:

    <script> function fbs_click() { u=location.href; t=document.title; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),' sharer', 'toolbar=0, status=0, width=626, height=436'); return false; } </script>
    Code (markup):
    to look like this:

    <script type='text/javascript' src='http://mysite.com/fbshare.js'></script>
    Code (markup):
    I've created a js file and put the codes into it ( which between <script> and </script> )

    and works in chrome and FF but not in IE :eek:

    could anyone help me? :(
     
    jonhyhar, Nov 14, 2009 IP
  2. lp1051

    lp1051 Well-Known Member

    Messages:
    163
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Hi,

    I guess, you included in your file fbshare.js the HTML <script> tag. When you include extern JS file, leave it pure JS. There should be only:
    function fbs_click() { u=location.href; t=document.title; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),' sharer', 'toolbar=0, status=0, width=626, height=436'); return false; }
    Code (markup):
    If IE doesn't still work, do you see at least something in the error message?
     
    lp1051, Nov 14, 2009 IP
  3. jonhyhar

    jonhyhar Active Member

    Messages:
    166
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    jonhyhar, Nov 14, 2009 IP
  4. lp1051

    lp1051 Well-Known Member

    Messages:
    163
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Hi,
    ok I looked and tested it. And the result is strange. IE stopped to complain after I trimmed the name of new window. Like so:
    
    function fbs_click() { u=location.href; t=document.title; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', 'toolbar=0, status=0, width=626, height=436'); return false; }
    
    Code (markup):
    Can you confirm?
     
    lp1051, Nov 14, 2009 IP
  5. jonhyhar

    jonhyhar Active Member

    Messages:
    166
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    still doens't work in IE :(
     
    jonhyhar, Nov 14, 2009 IP
  6. lp1051

    lp1051 Well-Known Member

    Messages:
    163
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #6
    lp1051, Nov 15, 2009 IP
  7. jonhyhar

    jonhyhar Active Member

    Messages:
    166
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #7
    jonhyhar, Nov 15, 2009 IP