iwato Posted July 3, 2017 Share Posted July 3, 2017 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 Link to comment Share on other sites More sharing options...
Ingolme Posted July 3, 2017 Share Posted July 3, 2017 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; } } ?> 1 Link to comment Share on other sites More sharing options...
iwato Posted July 3, 2017 Author Share Posted July 3, 2017 Ingolme: Very cool. My first practical use of the $_GET superglobal. I did not know that it was so easy to employ. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now