rammac13 Posted October 20, 2008 Share Posted October 20, 2008 Does anyone know of a way to detect what is in the title tag of a page? What I am attempting to do is have some code that will detect whatever the title of my page is and input it directly into a tag cloud that will be at the bottom of the page. Any Ideas? In any Language? Quote Link to comment https://forums.phpfreaks.com/topic/129321-detect-title-tag/ Share on other sites More sharing options...
discomatt Posted October 20, 2008 Share Posted October 20, 2008 Why not define the page title with PHP? Otherwise, you're stuck on regex. preg_match('/<title[^>]*+>([^<]++)/i', $subject, $regs); echo $regs[1]; Quote Link to comment https://forums.phpfreaks.com/topic/129321-detect-title-tag/#findComment-670447 Share on other sites More sharing options...
DarkWater Posted October 20, 2008 Share Posted October 20, 2008 Wait, are you trying to get the page title of a page that you're actually on right now...like, the PHP script that's running is actually creating this page? Then why don't you just create the title in PHP? =/ Quote Link to comment https://forums.phpfreaks.com/topic/129321-detect-title-tag/#findComment-670454 Share on other sites More sharing options...
rammac13 Posted October 20, 2008 Author Share Posted October 20, 2008 How do you make the title in PHP. I am new Quote Link to comment https://forums.phpfreaks.com/topic/129321-detect-title-tag/#findComment-670478 Share on other sites More sharing options...
DarkWater Posted October 21, 2008 Share Posted October 21, 2008 ...You just echo something out in a <title> tag. Quote Link to comment https://forums.phpfreaks.com/topic/129321-detect-title-tag/#findComment-670482 Share on other sites More sharing options...
rammac13 Posted October 21, 2008 Author Share Posted October 21, 2008 Ok so I think I am getting close. I am trying to put the title name (link) into a link on the page. but I am not sure how to call it correctly. I have javascript:tagLink in the a href link but that is not correct. What am I missing. Thanks. <html> <head> <title> link </title> <script type="text/javascript"> function getTagCloudLink() { var tagLink = document.getElementsByTagName("title")[0].innerHTML ; } </script> </head> <body> <p><a href="shop-enzy.com/store/index.html()">javascript:tagLink</a></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/129321-detect-title-tag/#findComment-670999 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.