Javascript Question

  • Thread starter Thread starter Smackrazor
  • Start date Start date
S

Smackrazor

Guest
Well, since I haven't bugged anyone about JS recently I decided I should :)

Anyway, I was wondering if it was possible to strip out the http:// that is infront of a url? (for a context menu in MSIE)

[a href=//fallout.gamestats.com/pipboy2000le/][IMG SRC=//fallout.gamestats.com/pipboy2000le/img/tmslogo.gif" border=0][/a]

[a href="mailto: Smackrazor@mailandnews.com" style="font-family:arial;font-size: 9pt;color:#008DE6;text-decoration:underline;]Smackrazor[/a]

[font style=font-family:arial;font-size: 9pt;color:#008DE6;]The Modding Kingpin​
 
>Well, since I haven't bugged anyone
>about JS recently I decided
>I should :)
>
>Anyway, I was wondering if it
>was possible to strip out
>the http:// that is infront
>of a url? (for a
>context menu in MSIE)

In Actionscript which is similar to Javascript, I can use the substring () function to grab the characters from a certain location of a string and then use it to compare with. Then if the string matches, copy all the characters after the block you copied before to your new string.

-Xotor-

[div align=center]

http://www.poseidonet.f2s.com/files/nostupid.gif
[/div]
 
Ok, so far I have this:

[pre]

<SCRIPT LANGUAGE=JavaScript" defer>

var dp = window.open ("", "deproxy", "width=302,height=50,toolbar=no,directories=no,location=no");
var docDP = dp.document;
docDP.open();

docDP.writeln ("<HTML>");
docDP.writeln ("<HEAD>");
docDP.writeln ("<TITLE>DeProxy</TITLE>");
docDP.writeln ("</HEAD>");
docDP.writeln ("<BODY marginwidth=0 marginheight=0 topmargin=0 vlink='blue' leftmargin=0 onBlur='focus();' onLoad='focus();window.resizeTo(\"312\",\"134\");'>");
docDP.writeln ("
");
docDP.writeln ("<font face='XBAND Rough' style='font-size:16pt;'> DeProxy[main]</font> [right click to go]
");
docDP.writeln ("<input type=text size=32 value=" + external.menuArguments.location.href + ">
");
docDP.writeln ("<center>[ Close ]</center>
");
docDP.writeln ("</BODY>");
docDP.writeln ("</HTML>");

</script>
[/pre]

Now what I was thinking was take the value for the text input and subract 7 from it... if that's possible. There's a replace method <stringObj.replace(rgExp, replaceText)> but I'm not sure if it will work or not. Has anyone seen another way to do this?

>>Well, since I haven't bugged anyone
>>about JS recently I decided
>>I should :)
>>
>>Anyway, I was wondering if it
>>was possible to strip out
>>the http:// that is infront
>>of a url? (for a
>>context menu in MSIE)
>
>In Actionscript which is similar to
>Javascript, I can use the
>substring () function to grab
>the characters from a certain
>location of a string and
>then use it to compare
>with. Then if the
>string matches, copy all the
>characters after the block you
>copied before to your new
>string.
>
>-Xotor-
>
>[div align="center]

>http://www.poseidonet.f2s.com/files/nostupid.gif
>[/div]


[a href=//fallout.gamestats.com/pipboy2000le/][IMG SRC=//fallout.gamestats.com/pipboy2000le/img/tmslogo.gif" border=0][/a]

[a href="mailto: Smackrazor@mailandnews.com" style="font-family:arial;font-size: 9pt;color:#008DE6;text-decoration:underline;]Smackrazor[/a]

[font style=font-family:arial;font-size: 9pt;color:#008DE6;]The Modding Kingpin​
 
>Now what I was thinking was take the value for the text input and subract 7 from it... if that's possible. There's a replace method <stringObj.replace(rgExp, replaceText)> but I'm not sure if it will work or not. Has anyone seen another way to do this?

I'd do a string compare with the first seven ("http://") characters of the string and if they match the above string, then copy all the characters after those first seven. If not, use the entire string. Javascript definitely has the ability to do this.

-Xotor-

[div align=center]

http://www.poseidonet.f2s.com/files/nostupid.gif
[/div]
 
Ok, great! Now for my next question, I wanted borderless windows so I have a window open up from a context menu, but for some reason the onLoad function stops working, so I cannot have it resize. I also tried meta refresh and history.go(0) with setInterval, however these failed too.

Now I was wondering if it was possible to pass data from one window to another using JS? Is it execScript() or something?

>>Now what I was thinking was take the value for the text input and subract 7 from it... if that's possible. There's a replace method <stringObj.replace(rgExp, replaceText)> but I'm not sure if it will work or not. Has anyone seen another way to do this?
>
>I'd do a string compare with
>the first seven ("http://") characters
>of the string and if
>they match the above string,
>then copy all the characters
>after those first seven.
>If not, use the entire
>string. Javascript definitely has
>the ability to do this.
>
>
>-Xotor-
>
>[div align=center]

>http://www.poseidonet.f2s.com/files/nostupid.gif
>[/div]


[a href=//fallout.gamestats.com/pipboy2000le/][IMG SRC=//fallout.gamestats.com/pipboy2000le/img/tmslogo.gif" border=0][/a]

[a href="mailto: Smackrazor@mailandnews.com" style="font-family:arial;font-size: 9pt;color:#008DE6;text-decoration:underline;]Smackrazor[/a]

[font style=font-family:arial;font-size: 9pt;color:#008DE6;]The Modding Kingpin​
 
>Ok, great! Now for my next
>question, I wanted borderless windows
>so I have a window
>open up from a context
>menu, but for some reason
>the onLoad function stops working,
>so I cannot have it
>resize. I also tried meta
>refresh and history.go(0) with setInterval,
>however these failed too.

Your menu script (HeirMenus?) is probably installing its own onLoad function that overwrites the body tag's. I've seen this happen.

>Now I was wondering if it
>was possible to pass data
>from one window to another
>using JS? Is it execScript()
>or something?

I think you can only if you created the window and know its name.

-Xotor-

[div align=center]

http://www.poseidonet.f2s.com/files/nostupid.gif
[/div]
 
>>Ok, great! Now for my next
>>question, I wanted borderless windows
>>so I have a window
>>open up from a context
>>menu, but for some reason
>>the onLoad function stops working,
>>so I cannot have it
>>resize. I also tried meta
>>refresh and history.go(0) with setInterval,
>>however these failed too.
>
>Your menu script (HeirMenus?) is probably
>installing its own onLoad function
>that overwrites the body tag's.
> I've seen this happen.


HeirMenus? I hand coded everything myself so I know exactly what's going on... almost :)

Can I reload the window from the script which launches it?

>
>>Now I was wondering if it
>>was possible to pass data
>>from one window to another
>>using JS? Is it execScript()
>>or something?
>
>I think you can only if
>you created the window and
>know its name.

Ok, well I do... do you know the method?

>-Xotor-
>
>[div align=center]

>http://www.poseidonet.f2s.com/files/nostupid.gif
>[/div]


[a href=//fallout.gamestats.com/pipboy2000le/][IMG SRC=//fallout.gamestats.com/pipboy2000le/img/tmslogo.gif" border=0][/a]

[a href="mailto: Smackrazor@mailandnews.com" style="font-family:arial;font-size: 9pt;color:#008DE6;text-decoration:underline;]Smackrazor[/a]

[font style=font-family:arial;font-size: 9pt;color:#008DE6;]The Modding Kingpin​
 
>HeirMenus? I hand coded everything myself
>so I know exactly what's
>going on... almost :)

HeirMenus is a very nice DHTML menu system. Even the Merril-Lynch website uses it.

>Can I reload the window from
>the script which launches it?

>Ok, well I do... do you
>know the method?

I haven't coded Javascript in a long time. I used to know it quite well a few years ago, but since I don't really bother with it so much anymore, I don't know. Maybe try www.javascript.org, I know I used to frequent there a lot a few years ago.

-Xotor-

[div align=center]

http://www.poseidonet.f2s.com/files/nostupid.gif
[/div]
 
>>HeirMenus? I hand coded everything myself
>>so I know exactly what's
>>going on... almost :)
>
>HeirMenus is a very nice DHTML
>menu system. Even the
>Merril-Lynch website uses it.

I'm creating a context menu, perhaps I need to specify what one is. I went into my registry and added a HTML page to it so that no matter which page or site I was on I could right click and this window would open up. So far it works apart from the fact that I need to transfer data from one window to another.


[a href=//fallout.gamestats.com/pipboy2000le/][IMG SRC=//fallout.gamestats.com/pipboy2000le/img/tmslogo.gif" border=0][/a]

[a href="mailto: Smackrazor@mailandnews.com" style="font-family:arial;font-size: 9pt;color:#008DE6;text-decoration:underline;]Smackrazor[/a]

[font style=font-family:arial;font-size: 9pt;color:#008DE6;]The Modding Kingpin​
 
Back
Top