0

My header has an image logo but it won't show if I have the triggered click to download a file:

 $("#test").click();

If I remove this script and try clicking on the text manually, the header image shows okay. The link's:

<span id="test" onclick="window.location.href='http://www.example.com/download.php';"> . </span>

Why is this so? What's causing this problem? Why does a triggered click behave differently than manual click on a link?

Is there something as a conflict on the image and jquery. Is that conflict even possible?

Leah
  • 225
  • 2
  • 10
  • 24
  • Can you provide us with some more code? You have tagged this as php but i can't see any php code? – Konstig Aug 01 '13 at 15:39
  • sorry. I tagged this php coz maybe it has something to do with downloading a file on another php file . not really sure what's causing this problem – Leah Aug 01 '13 at 15:42
  • This > `. `. **Q:** Are you trying to [**concatenate**](http://php.net/manual/en/language.operators.string.php) something? I can't tell without seeing your full code. – Funk Forty Niner Aug 01 '13 at 15:46
  • No. That is just a period to be displayed.. It could be any text. But since the site's live and anyone could see a test text there, I just placed a period. that is the text i'm trying to click. – Leah Aug 01 '13 at 15:50
  • @SandaraKwon Ok, well without seeing your entire code, I or anyone else cannot be certain as to what may be causing the problem. **P.s.:** Please add the `@` symbol followed by my name, in order to address me personally, it helps. (wink) Cheers – Funk Forty Niner Aug 01 '13 at 15:56
  • @SandaraKwon Try using this `$("#test span").click();` see if that works then get back to me. – Funk Forty Niner Aug 01 '13 at 16:02
  • Are you sure you're callin $("#test").click() after the document has loaded? – Trunal Bhanse Aug 01 '13 at 16:22
  • @TrunalBhanse Yes, $("#test").click(); is working since it is downloading the file fine (meaning it was able to click on the link) – Leah Aug 01 '13 at 23:36
  • @Fred Tried $("#downloadNow span").click(); but it's not working.. Instead of downloading the file, nothing happens now as if the link has not been clicked. – Leah Aug 01 '13 at 23:38
  • Basically, the click is working fine just as I want it. The only problem is the logo image on the header. It's there since I can see it when I do inspect element on chrome but can't be seen on display. If I remove or comment out $("#test").click(); , the image will show and clicking on the link manually works. Is there something as a conflict on the image and jquery. Is that conflict even possible? – Leah Aug 01 '13 at 23:43
  • It's hard for me to say without seeing the actual full source and/or Web site @SandaraKwon – Funk Forty Niner Aug 02 '13 at 00:43
  • @Fred well, those two are the only important codes.. the rest are just html to design the page.. is there a way to load the image first before the triggered click is executed? – Leah Aug 02 '13 at 03:09
  • @SandaraKwon Again, I can't tell without seeing your entire source. I could pick at straws to say: Use `` and delete the header image from inside your JS, yet I can guess "till the cows come home", and I stand at still being wrong. Until you show your full HTML and with the header image's name, I can no longer help you. – Funk Forty Niner Aug 02 '13 at 03:16
  • @Fred
    .
    – Leah Aug 02 '13 at 04:38
  • @SandaraKwon Is your JS `` inside `` or ``? – Funk Forty Niner Aug 02 '13 at 04:55
  • @SandaraKwon Try putting it inside `` see if that will work and make your header image appear. Other than that, all I can think of is, if you haven't another nested `
    ` that they're both inside. Also, this could be a CSS issue. Check and see if you have a `hidden` statement inside CSS (`#myheader` and `#logo`). I take it you do have CSS happening. And check for `z-index` and `position`. Also, check to see the location of `logo.jpg` if the `src` is correct and not inside another folder. That's all I can think of for the moment.
    – Funk Forty Niner Aug 02 '13 at 05:10
  • @Fred It's not an issue with css or img src.. Like i said, if i remove the script to trigger click, the image is there.. The image is not visible only when i have that ONE LINE of code which is $("#test").click(); – Leah Aug 02 '13 at 05:20
  • @SandaraKwon Sorry, at this point in time, I now need an actual visual. I can't wrap my head around it, sorry. Plus my brain has gone to mush. I hope you find what's wrong with it, as I can't help you with it, sorry Sandara I tried my best. Cheers *Peace* – Funk Forty Niner Aug 02 '13 at 05:23
  • @SandaraKwon You're welcome. Cheers *Peace* – Funk Forty Niner Aug 02 '13 at 05:57

1 Answers1

0

Looks like this could fall under the category "fake clicking", which is not supported. See Can I call jquery click() to follow an <a> link if I haven't bound an event handler to it with bind or click already?

Community
  • 1
  • 1
DavidW
  • 353
  • 2
  • 10