Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8364335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:24:28+00:00 2026-06-09T12:24:28+00:00

Long story short, im making a small website using ajax but its more for

  • 0

Long story short, im making a small website using ajax but its more for mobiles.

ive hijacked a few links and while testing on firebug, i get this error when clicking
links

TypeError: e.target is undefined
[Break On This Error]   

var myurl = e.target.href;

Now the thing is that although i get this error, it does work when i test it on a regular desktop and when i put on a mobile(ios) it also works and loads the AJAX content.

Reason i want to fix it is because…well aside from having an error, im having another small issue and im not sure if its because of this so, trying to fix one by one.

Heere are the two functions ive created to hijack the mobile sites links.

javascript:

//~~~~~~~~~~~~~~~~~~~~~~~~~~~functions for mobile index load AND hijacking app      

function loadPage(url){
        if( url == undefined){
            $('#contentHere').load('index.html #content', hijackLinks);
                window.location.hash = mainHash;
        } else {
            $('#contentHere').load(url + '#content', hijackLinks ); 
        }
    }


    function hijackLinks(e){
        var myurl = e.target.href;
        e.preventDefault();
        loadPage(myurl);
        mainHash = window.location.hash = $(this).attr("href");
        console.log(mainHash);

    }

Anyone can help me with this? how would i fix this?

Thanks in advanced.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:24:30+00:00Added an answer on June 9, 2026 at 12:24 pm

    e.target refers to the object (usually a DOM element) that originally triggered the event. If you are simply calling hijackLinks directly, rather than as an event handler, then of course e will not refer to an event and thus e.target is undefined. I’m guessing you’re also calling hijackLinks from a click handler or suchlike, therefore it will work as expected in that scenario.

    You have 2 options – either change the internals of hijackLinks to not rely on being passed an event as an argument (probably not a good idea), or just change all direct calls to hijackLinks to go through a DOM element event instead. For example, your original code:

    $('#contentHere').load('index.html #content', hijackLinks);
    

    Could be changed to:

    $('#contentHere').load('index.html #content', function() {
        $('a.whatever').trigger('click');
    });
    

    Change a.whatever selector to point to the actual link that is being hijacked (you haven’t shown any markup so I don’t know what that would be), then as long as you have correctly bound a click handler (or whatever UI interaction you require to trigger the event), you can rely on hijackLinks being called with an event argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Long story short, I'm making a racing game in Java. I'm self-taught using some
So long story short im working on a web app and using AJAX within
Long story short, I'm making a custom Swing component that's basically a JTable with
Long story short, the database I'm using needs to get looked at. Until that
Long story short, client's hosting is using php 5.2.5 and i desperately need to
So long story short, im trying to build a chat application....well its already built
Long story short, I'm creating a graph using networkx and the lower the weights
Long story short, I'm using a buggy WordPress template and we're too far into
Long story short I'm making a greasemonkey script. The pages I work on have
Long story short, I need to sort an array of objects using usort, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.