Jump to content
Sign in to follow this  
iwato

Executing PHP after window.open

Recommended Posts

RECENT DISCOVERY:  I recently discovered a handy PHP function called show_source( ) and would now like to apply it in a particular sort of way.
GOAL:  I would like to open a new tab in my current window that shows the source code of a page that I have opened in the window.

DILEMMA:  Since PHP operates before a page is opened I am a lot confused about how to make this happen.  This is what I have accomplished so far.

		$( document ).ready(function() {
			console.log( "ready!" );
			$('.show_src a').on('click', function(event) {
				event.preventDefault();
				var address = $(this).attr('href');
				window.open(address);
				...
			});
		});

		<li class='show_src'>The <a href='./composer/php_rss_generator/RSSGenerator/ItemInterface.php' title='' target='_blank'>Interface</a></li>
		<li class='show_src'>The <a href='./composer/php_rss_generator/RSSGenerator/Item.php' title='' target='_blank'>Class</a></li>

I have tried a variety of ways to replace the three dots above including .ajax( ) and window.write( ) but nothing seems to work.  Any ideas?

Roddy

Share this post


Link to post
Share on other sites

You'll have to link to a specific PHP file that's designed to display the source of a file.

<a href="show-source.php?file=interface">Interface</a>
<a href="show-source.php?file=class">Class</a>

show-source.php

<?php
if(isset($_GET['file'])) {
  switch($_GET['file']) {
    case 'interface':
      highlight_file('./composer/php_rss_generator/RSSGenerator/ItemInterface.php');
      break;
    case 'class':
      highlight_file('./composer/php_rss_generator/RSSGenerator/Item.php');
      break;
  }
}
?>

 

  • Like 1

Share this post


Link to post
Share on other sites

Ingolme:  Very cool.  My first practical use of the $_GET superglobal.  I did not know that it was so easy to employ.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...