Quantcast

javascript get host

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

javascript get host

jamil
Hi
for technical reasons I was forced not to use virtual hosts on my server.   thus I'm using the alias:
http://localhost/myproject to run myproject.

Everything runs fine except that when I'm using javascript location.host  returns : http://localhost/ instead of http://localhost/myproject

for example I want to use the link:
location.protocol + '//' + location.host + '/controller/action

this will become http://localhost/controller/action 
when it should be http://localhost/myproject/controller/action 

Does anybody have an idea of how to solve this?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: javascript get host

damir.mitrovic
This post was updated on .
Hi,

I think that in view you can use following:

location.protocol + '//' + location.host + '<?php echo
$this->baseUrl();?>/controller/action

Regards,
Damir Mitrovic

2010/10/4 JAmil [via Zend Framework Community]
<ml-node+2954570-205668268-137600@n4.nabble.com>:
> Hi
> for technical reasons I was forced not to use virtual hosts on my server.
> thus I'm using the alias:
> http://localhost/myproject to run myproject.
>
> Everything runs fine except that when I'm using javascript location.host
>  returns : http://localhost/ instead of http://localhost/myproject
>
> for example I want to use the link:
> location.protocol + '//' + location.host + '/controller/action
>
> this will become http://localhost/controller/action
> when it should be http://localhost/myproject/controller/action
>
> Does anybody have an idea of how to solve this?
>
>
>
> ________________________________
> View message @
> http://zend-framework-community.634137.n4.nabble.com/javascript-get-host-tp2954570p2954570.html
> To start a new topic under Zend Framework Community, email
> ml-node+634137-265097178-137600@n4.nabble.com
> To unsubscribe from Zend Framework Community, click here.
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: javascript get host

jamil
The problem is I am in a .js file
thus I cannot use php tags
Loading...