Solved

How to hide the value of src in an HTML frame?

Posted on 2010-08-26
13
739 Views
Last Modified: 2012-05-10
I want to use this code:
 <FRAMESET border=0 rows="100%,*" frameborder="no" marginleft=0 margintop=0 marginright=0 marginbottom=0>
        <frame src="http://www.google.com" scrolling=auto frameborder="no" border=0 noresize>
        <frame topmargin="0" marginwidth=0 scrolling=no marginheight=0 frameborder="no" border=0 noresize>
     </FRAMESET>

But i want to hide the value of src. How can i do this?

ASP.NET 1.1, Javascript, HTML
0
Comment
Question by:alexmac05
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 3

Expert Comment

by:shubham_gniiit
ID: 33534856
0
 

Author Comment

by:alexmac05
ID: 33535278
I am sorry. I don't know which part of the example above helps me? could you be more specific?

Thanks.
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33535335
do you want to remove the attribute? use removeAttribute() for the same
http://www.java2s.com/Tutorial/JavaScript/0420__HTML-Tags/RemoveattributebycallingtheremoveAttributefunction.htm

Could you be a more specific about hiding the attribute please? from whom are you hiding the attribute?
If you want you can always not specify the src value in html code, and do it via javascript eg

 <FRAMESET border=0 rows="100%,*" frameborder="no" marginleft=0 margintop=0 marginright=0 marginbottom=0>
        <frame id="frame1" scrolling=auto frameborder="no" border=0 noresize>
        <frame topmargin="0" marginwidth=0 scrolling=no marginheight=0 frameborder="no" border=0 noresize>
     </FRAMESET>

document.getElementById("frame1").setAttribute("src","http://www.google.com");
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:alexmac05
ID: 33535448
Hi Gurvinder372,

I am new to javascript, and your code isn't working. Am i missing something? did I place the document.getElementById("frame1")...etc... in the wrong location?

Thanks!

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <FRAMESET id="frame1" border=0 rows="100%,*" frameborder="no" marginleft=0 margintop=0 marginright=0 marginbottom=0>
        <frame scrolling=auto frameborder="no" border=0 noresize>
        <frame topmargin="0" marginwidth=0 scrolling=no marginheight=0 frameborder="no" border=0 noresize>
     </FRAMESET>
      document.getElementById("frame1").setAttribute("src","http://www.google.com");
</head>


</html>
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33535532
yes,

it should be


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
 
</head>

    <FRAMESET id="frame1" border=0 rows="100%,*" frameborder="no" marginleft=0 margintop=0 marginright=0 marginbottom=0 onload="putSource()">
        <frame scrolling=auto frameborder="no" border=0 noresize>
        <frame topmargin="0" marginwidth=0 scrolling=no marginheight=0 frameborder="no" border=0 noresize>
     </FRAMESET>

    <script>
     function putSource()
    {
      document.getElementById("frame1").setAttribute("src","http://www.google.com");
    }
    </script>

</html>
0
 

Author Comment

by:alexmac05
ID: 33535924
Thanks Gurvinder372. I think this is very close to a solution. for some reason it doesn't render the google.com page though.

I uploaded the code cut and paste from your post. Does it work for you? There must be something very small wrong with it. I tried to troubleshoot it myself but I wasn't able to make it have google.com appear.

thanks again

ps: rename it to test.html


test.html.txt
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33536065
ohh...my bad...i think using javascript you cannot set a location of different domain of a frame, due to same origin policy.

try this
 Was this comment helpful?
Yes No
gurvinder372:
yes,

it should be


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
 
</head>

    <FRAMESET id="frame1" border=0 rows="100%,*" frameborder="no" marginleft=0 margintop=0 marginright=0 marginbottom=0 onload="putSource()">
        <frame scrolling=auto frameborder="no" border=0 noresize>
        <frame topmargin="0" marginwidth=0 scrolling=no marginheight=0 frameborder="no" border=0 noresize>
     </FRAMESET>

    <script>
     function putSource()
    {
      document.getElementById("frame1").innerhtml = document.getElementById("frame1").innerhtml  + "<frame scrolling=auto frameborder='no' border=0 noresize src='http://www.google.com' >";
    }
    </script>

</html>
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
ID: 33536078
sorry ignore last post

ohh...my bad...i think using javascript you cannot set a location of different domain of a frame, due to same origin policy.

try this

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
 
</head>

    <FRAMESET id="frame1" border=0 rows="100%,*" frameborder="no" marginleft=0 margintop=0 marginright=0 marginbottom=0 onload="putSource()">
        <frame topmargin="0" marginwidth=0 scrolling=no marginheight=0 frameborder="no" border=0 noresize>
     </FRAMESET>

    <script>
     function putSource()
    {
      document.getElementById("frame1").innerhtml = document.getElementById("frame1").innerhtml  + "<frame scrolling=auto frameborder='no' border=0 noresize src='http://www.google.com' >";
    }
    </script>

</html>
0
 

Author Comment

by:alexmac05
ID: 33536137
That doesn't work either. does it work for you?
Thanks again for your help.
0
 
LVL 5

Assisted Solution

by:wmadrid1
wmadrid1 earned 250 total points
ID: 33539560
Hello,
The code of gurvinder372 could work if you try it with IFRAME tag

Trythe code below with a changes i made, i tested it over Firefox 3.6.8


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>

    <IFRAME id="frame1" border=1 width="100%" height="100%" frameborder="no" marginleft=0 margintop=0 marginright=0 marginbottom=0></IFRAME>

    <script>
     function putSource()
    {
      document.getElementById("frame1").src='http://www.google.com';
    }
	putSource();
    </script>
</body>
</html>

Open in new window

0
 

Author Comment

by:alexmac05
ID: 33541954
yes, this works. Thank you!

The only thing left to do with this code is to hide the URL using javascript. Once that happens, then that is the solution.

Any idea how to do that? It would be ideal to call a ASP.NET function to provide the link. is that possible?

Basically, I want to set the src value in the code behind C# code or using javascript somehow, so that if the user does a view source they can't see the value.

document.getElementById("frame1").src='http://www.google.com';

Any ideas?

Thanks so much.
0
 

Author Comment

by:alexmac05
ID: 33544796
I am moving to a behind the scenes back end solution to this problem.

Thanks everyone for helping.
0
 
LVL 5

Expert Comment

by:wmadrid1
ID: 33546519
You can try it, using AJAX
Calling any script language (PHP, .NET, etc)
And in the response of script set the
document.getElementById("frame1").src='http://www.google.com';

Below is the code, to do the AJAX call

The call for it, could be like this
    <script>
     function putSource()
    {
      getAjax("URL of the .NET script ");
    }
        putSource();
    </script>

You can put the below code in a library and cerypt the javascript, to get the reading of it more dificult

<script>
var conn; 	//Conn object

function getAjax(page)
{
	conn = getXMLHttpRequester();
	conn.onreadystatechange = process;
	conn.open('GET',page, true);
	conn.send(null);
}

function process()
{
	if(conn.readyState == 4)
	{
		if (conn.status == 200) 
		{
			//HERE WE EXECUTE THE reponse javascript from .NET
			eval(conn.responseText);
			conn.abort();
		}
	} 
}

function getXMLHttpRequester()
{
    var xmlHttpRequest = false;
    try
    {
        if(window.ActiveXObject)
        {
            for(var i = 5; i; i--)
            {
                try
                {
                    if(i == 2)
                    {
                        xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");    
                    } else {
                        xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP." + i + ".0");
                    }
                    break;
                }
                catch(excNotLoadable)
                {
                    xmlHttpRequest = false;
                }
            }
        }
        else if(window.XMLHttpRequest)
        {
            xmlHttpRequest = new XMLHttpRequest();
        }
    }
    
    catch(excNotLoadable)
    {
        xmlHttpRequest = false;
    }
    
    return xmlHttpRequest;
}
</script>

Open in new window

0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question