1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Put function in external file?

Discussion in 'JavaScript' started by bellcom, Feb 7, 2014.

  1. #1
    I wrote some code to use on ebay ads, I just paste the html into the editor window used for creating ads on ebays website. I was able to include an external css file from another site and at the bottom of page I have javascript that controls tabbed content in the content area.

    Here is what the ad looks like:
    http://virtualgeorge.info/ultra/ebay.htm

    I was wondering if I can put the javascript function that have in the code in an external file?
    When I paste the code into the box, sometimes by end brackets on the <script> tags get changed to
    &lt;script&gt; for some reason?

    The code for the tabbed content that I included in the html but I would like to put into an external file is this:

    Code (Text):
    1. <script type="text/javascript">
    2. function tab(tab) {
    3. document.getElementById('description').style.display = 'none';
    4. document.getElementById('payment').style.display = 'none';
    5. document.getElementById('shipping').style.display = 'none';
    6. document.getElementById('terms_of_sale').style.display = 'none';
    7. document.getElementById('about_us').style.display = 'none';
    8. document.getElementById('li_tab1').setAttribute("class", "");
    9. document.getElementById('li_tab2').setAttribute("class", "");
    10. document.getElementById('li_tab3').setAttribute("class", "");
    11. document.getElementById('li_tab4').setAttribute("class", "");
    12. document.getElementById('li_tab5').setAttribute("class", "");
    13. document.getElementById(tab).style.display = 'block';
    14. document.getElementById('li_'+tab).setAttribute("class", "active");
    15. }
    16. </script>
    Any suggestions much appreciated!!
    bellcom, Feb 7, 2014 IP
  2. HuggyStudios

    HuggyStudios Active Member

    Messages:
    663
    Likes Received:
    18
    Best Answers:
    21
    Trophy Points:
    90
    #2
    I doubt eBay would allow you to insert JavaScript as it could be a security problem. The reason you are seeing your tags changed is because they are converting the tags to their entity which will make the browser not render it as actual code.
    HuggyStudios, Feb 7, 2014 IP
  3. bellcom

    bellcom Member

    Messages:
    107
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    35
    #3
    The code doesn't always change and the page does show fine.
    Seems like it does it when using IE instead of Firefox or maybe its when changing the editor from standard mode to html mode and making minor changes is when it converts the code.
    If I just paste in the code and save its fine.

    Maybe I could do the tabbed content with css instead of javascript?
    bellcom, Feb 7, 2014 IP
  4. ThePHPMaster

    ThePHPMaster Active Member

    Messages:
    596
    Likes Received:
    30
    Best Answers:
    18
    Trophy Points:
    75
    #4
    You are correct. Once you switch from standard mode to html mode and then make a change and saving, it will convert all applicable characters to HTML entities (including < and >), regardless of the browser.

    The way I do it is that I make the modifications on html mode, then before saving switching back to standard mode so all my HTML code stays intact.
    ThePHPMaster, Feb 12, 2014 IP