Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing page title 1

Status
Not open for further replies.

benrob82

Programmer
Jul 28, 2005
116
GB
Hi all,

i have this code in the header of my page to read the first line of my html containing <h2> and then pull this out to be my page title but it doesn't seem to be working can anyone see why?

<%
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("c:\Temp\page1.asp")
Set objTextStream = objFile.OpenAsTextStream(ForReading)

Do Until objTextStream.AtEndOfStream
strLine = LCase(objTextStream.ReadLine())

If InStr(strLine, "<h2>") Then
Exit Do
End If
Loop

Set objTextStream = Nothing
Set objFile = Nothing
Set objFSO = Nothing

strLine = Replace(strLine, "<h2>", "")
strLine = Replace(strLine, "</h2>", "")
%>


thanks
 
it should work...make sure you have the exact string without any spaces...

also what is your complete string and how would want to make it look...

-DNG
 
i did, it is how it appears exactly in the code. There are no spaces and I have copied and pasted it.
 
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<link REL="SHORTCUT ICON" HREF="/content/80000/favicon.ico" >
<link REL="STYLESHEET" HREF="/home/site/80000/styles/style.css" TYPE="text/css">
<title><!---@orchidnet~content@--->this is just a test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<table class="MainSiteTable" summary="Main site table">
<tr>
<td width="6" background="/webimages/siteborder/shadow_left.gif" alt=""><img src="/webimages/spacer.gif" alt="" width="6" height="1"></td>
<td valign="top">
<!--headerBar-->

<table border="0" summary="Header Bar Table" cellpadding="0" cellspacing="0" width="715">  
  <tr> 
    <td><img src="/webimages/spacer.gif" width="231" height="1" border="0" alt=""></td>
    <td><img src="/webimages/spacer.gif" width="484" height="1" border="0" alt=""></td>
    <td><img src="/webimages/spacer.gif" width="1" height="1" border="0" alt=""></td>
  </tr>
  <tr> 
    <td colspan="2"><img name="gfx_mainphoto1" src="/webimages/headers/abstract.jpg" border="0" alt="Title Banner"></td>
    <td><img src="/webimages/spacer.gif" width="1" height="122" border="0" alt=""></td>
  </tr>
  <tr> 
    <td colspan="2"><img name="gfx_lowerhbar" src="/webimages/gfx_lowerhbar.gif" width="715" height="26" border="0" alt=""></td>
    <td><img src="/webimages/spacer.gif" width="1" height="26" border="0" alt=""></td>
  </tr>
</table>

<!--/headerBar-->

<!-- mainBodyTable-->
  <table border="0" summary="Top Table Format" cellpadding="0" cellspacing="0" width="715">
    <tr> 
      <!--content-->      
      <td valign="top"> 
        <table width="100%" summary="Top Sub Section" border="0" cellpadding="0" cellspacing="0">
	  <tr>
	  <td colspan="3"><img src="/webimages/spacer.gif" alt=" " name="" width="10" height="10" border="0"></td></tr>	  
	  <tr>
	  <td><img src="/webimages/spacer.gif" alt=" " name="undefined_4" width="10" height="1" border="0"></td>
	  <td width="100%">

<!---@ORCHIDNET~CONTENT@---><H2>this is just a test</H2>
<P>hopefully this will work</P><!---/@ORCHIDNET~CONTENT@--->
</td>

thanks
 
if you notice in the orginal code I gave you,. I used LCase() to force the characters in the line to lowercase.

Because of this you need to use lowercase in your Replace:
Code:
strLine = Replace(strLine, "<!---@orchidnet~content@--->", "")

Tony

Spirax-Sarco - steam traps control valves heat exchangers
Sun Villa - Luxury Florida accommodation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top