-3

I am working on a web project.Everything is placed inside iframe.After opening project in url, when I click any link or open any page , I have to find location of the opened page in my project directory(i.e.localhost).Anyone have any idea?I tried everything I could but couldn't solve the problem.

Thank you in advance.

Sajal
  • 3
  • 5
  • Please clarify your question. Are you asking to find the local file path of the file in the PHP code? Btw, why is this tagged with javascript, html and css? – M. Eriksson Dec 01 '16 at 06:40
  • 1
    What you have tried before? show some code and update your question. – Ataur Rahman Munna Dec 01 '16 at 06:44
  • After opening project in url, when I click any link or open any page , I have to find location of the opened page in my project directory(i.e.localhost) . – Sajal Dec 01 '16 at 06:44
  • 1
    Repeating what's already is in the question doesn't clarify things. – M. Eriksson Dec 01 '16 at 06:45
  • While you develop, why not access the site directly, without the iframe?Then you can see the URL in the browser? – M. Eriksson Dec 01 '16 at 06:47
  • Example:lets say I have a social network.When I click profile,I need to find that page.Similarly,if I click add_ friend page,I need to find which page contains the code of that page in my computer server. – Sajal Dec 01 '16 at 06:49
  • Is site built with PHP? Are you using some framework with a router? mod_rewrite? There are too many unknowns to be able to answer your question. – M. Eriksson Dec 01 '16 at 06:50
  • I tried xdebug to find location.... – Sajal Dec 01 '16 at 06:51
  • yes the site is built in core php..... – Sajal Dec 01 '16 at 06:52
  • Project uses javascript,html,css so I just listed them.... – Sajal Dec 01 '16 at 06:53
  • 1
    Your question is way too broad, since there still are too many unknowns. Regarding your tags, only add tags that's relevant for your actual issue in your question. – M. Eriksson Dec 01 '16 at 06:55
  • This sounds an awful lot like "How do you make a hyperlink?" to me. – GordonM Dec 01 '16 at 09:46

1 Answers1

0

You can comminucate with your iframe by message event. Just look at postMessage.

  1. Your app in iframe have to send information about file, e.g:

    var message = {type: 'fileInfo', path: yourFilePath}
    window.parent.postMessage(message, targetOrigin);
    

    (yourFilePath you have to set into JS from your PHP code)

  2. Your app in main window can catch this message:

    window.addEventListener("message", function(event) {
        if (event.origin !== YOUR_ORIGIN) return;
    
        if (event.data.type === 'fileInfo') {
            var filePath = event.data.path;
            //do something
        }
    }, false);
    
poletaew
  • 197
  • 2
  • 12
  • I'd advise against trying to answer questions as poor as this one. It will only encourage more poor questions. – GordonM Dec 01 '16 at 09:47
  • Hm, but is there any a clear boundary between poor and non-poor questions? I thought I had clearly understood this problem. P.S. Maybe lazy answerers aren't better than lazy questioners? :) – poletaew Dec 01 '16 at 10:30
  • The question doesn't describe a specific problem or show any evidence on the part of the poster that they have attempted to figure out a solution. There's no code, no description of the expected result versus the actual result, etc. – GordonM Dec 01 '16 at 12:10
  • OK, I've understood your position – poletaew Dec 02 '16 at 06:12