Javascript Parent Directory -


ok, let me explain this. site layout (for example)

    localhost/mydomain/     -localhost/mydomain/pics     -localhost/mydomain/somepages/arandompage.php 

so on page localhost/mydomain/index.php

//(thumbnail rotator)//

<img id='4' src='pics/somepic.1.jpg'> 

the mouseover snippet

{ $('#'+someid).attr('src', 'pics/somepic.'+num+'.jpg'); 

//no need me include rest since works. works on localhost/mydomain/index.php when go localhost/mydomain/somepages/arandompage.php doesn't work, no longer relative.

<img id='4' src='../pics/somepic.1.jpg'> 

ok here that'll fix display image...but have tried searched everywhere javascript go 1 directory..

{ $('#'+videoid).attr('src', '../pics/somepic.'+num+'.jpg'); //doesn't work 

i don't know here, yes need javascript 1 folder img src. thats all... after 8+ hours damn near given because seems simple not find answer, please if know please respond. , if answer please insert should here in

`{ $('#'+videoid).attr('src', ====> 'pics/somepic.'+num+'.jpg');`  

so goes parent directory.

p.s. tried absolute paths no avail either.

the key thing remember browser's view of hierarchy is:

  1. assuming localhost/mydomain root of site, then:

    ...a page localhost/mydomain/somepage.php:

    • will appear @ e.g. http://example.com/somepage.php browser's pov

    • and can use pics/somepic.jpg or /pics/somepic.jpg pic.

    ...a page localhost/mydomain/somepages/somepage.php:

    • will appear @ e.g. http://example.com/somepages/somepage.php browser's pov

    • and can use ../pics/somepic.jpg or /pics/somepic.jpg pic.

  2. assuming localhost root of site instead, then:

    ...a page localhost/mydomain/somepage.php

    • will appear @ e.g., http://example.com/mydomain/somepage.php browser's pov

    • and can use pics/somepic.jpg or /mydomain/pics/somepic.jpg pic.

    ...a page localhost/mydomain/somepages/somepage.php

    • will appear @ e.g., http://example.com/mydomain/somepages/somepage.php browser's pov

    • and can use ../../pics/somepic.jpg or /mydomain/pics/somepic.jpg pic.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -