1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Create thread javascript h1 issue

Discussion in 'Resolved Bug Reports' started by Mike Creuzer, Dec 26, 2013.

  1. Mike Creuzer

    Mike Creuzer Well-Known Member

    In xenforo.js around line 7355, there is the function to update the page title h1 with the content you are typing while creating a thread title.


    if (!$title.length)
           $title = $('h1').first();
    And I found this to not work very well with my site, as my logo is an <h1>. I have a fixed navigation and I need the header to be moved back to the top, thus making this cause the issue. To fix my issue, I've simply changed MY code to be an <h2> which isn't ideal for search engines. The fix I think would work is to make the $title object something more specific:

    $title = $('.pageTitle h1');

    Attached Files:

    rellect likes this.
  2. Chris D

    Chris D XenForo Developer Staff Member

    I would argue that wrapping your logo in h1 tags isn't the best move. I read an article recently and this sums it up quite well:

    And generally I think it's a bad idea to have more than one H1 tag on a page.
    Mike Creuzer likes this.
  3. Mike Creuzer

    Mike Creuzer Well-Known Member

    Fair argument, but regardless I think that it is a bit dangerous to assume we all know the best standards and we can use the tags within reason how we see fit, and so when selecting something that is going to change due to a specific function, it should in my opinion be a bit more specific than "first on the page" and rather selected by an ID or a class.
    Adam Howard likes this.
  4. Mike

    Mike XenForo Developer Staff Member

    I have changed this in 1.3, but not before to prevent possible BC break issues with custom styles.

    Note that in general, in the past, there has been an assumption of only 1 h1 per page (this was a very common SEO recommendation).
    Mike Creuzer likes this.
  5. Mike Creuzer

    Mike Creuzer Well-Known Member

    Yes, I read that as well. So I understand why it was done. But yeh I think its still a good idea because some people might not understand best practices, such as myself before @Chris Deeming mentioned it.
  6. Chris D

    Chris D XenForo Developer Staff Member

    @Mike for more flexibility is it worth allowing the target element to be passed using a data attribute? Might there be some use cases where you'd want to show the live title elsewhere on the page instead of the h1 tag?

    The default could be the new specific selector you've added but being able to override it using a data attrib would be nice.

Share This Page