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:
    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:

    <script type="text/javascript">
    function tab(tab) {
    document.getElementById('description').style.display = 'none';
    document.getElementById('payment').style.display = 'none';
    document.getElementById('shipping').style.display = 'none';
    document.getElementById('terms_of_sale').style.display = 'none';
    document.getElementById('about_us').style.display = 'none';
    document.getElementById('li_tab1').setAttribute("class", "");
    document.getElementById('li_tab2').setAttribute("class", "");
    document.getElementById('li_tab3').setAttribute("class", "");
    document.getElementById('li_tab4').setAttribute("class", "");
    document.getElementById('li_tab5').setAttribute("class", "");
    document.getElementById(tab).style.display = 'block';
    document.getElementById('li_'+tab).setAttribute("class", "active");
    Code (markup):
    Any suggestions much appreciated!!
    bellcom, Feb 7, 2014 IP
  2. HuggyStudios

    HuggyStudios Well-Known Member

    Likes Received:
    Best Answers:
    Trophy Points:
    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 Active Member

    Likes Received:
    Best Answers:
    Trophy Points:
    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 Well-Known Member

    Likes Received:
    Best Answers:
    Trophy Points:
    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