Solved

ust html in ms/access WebBrowswer

Posted on 2016-10-11
11
77 Views
Last Modified: 2016-11-16
In order to have control  of the parameters that I need to send to google maps (to be shown embedded in a control on a web form, according to Google Maps, I need to be able to "store" either a javascript or a html script in it, for which I can find no manner to do.

By googling a bit, I found the following suggestion on stack exchange:

Well, I decided to use the ActiveX WebBrowser control instead of the native WebBrowser for Access 2010/2013 since the former accepts the html string and formats the document correctly by using the write property of the document.

QUOTE
With Me.WebBrowser6.Object
    .Navigate2 "about:blank"
    .Document.write rst.Fields(2)
    .Refresh
End With

UNQUOTE

but nothing happens

can anyone help me?
0
Comment
Question by:jirdeaid
[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
11 Comments
 
LVL 34

Expert Comment

by:ste5an
ID: 41840407
Well, I decided to use the ActiveX WebBrowser control instead of the native WebBrowser for Access 2010/2013 since the former accepts the html string and formats the document correctly by using the write property of the document.

D'oh? WebBrowser can do this also.

But .Refresh is not necessary nor does it something useful here.
0
 

Author Comment

by:jirdeaid
ID: 41840502
The question is: How does it?
0
 
LVL 34

Accepted Solution

by:
ste5an earned 500 total points
ID: 41840526
Misunderstood your post. Use ActiveX instead:

With Me.WebBrowser6.Object
     .Navigate "about:blank"
     .Document.write "<h1>Test</h1>
 End With

Open in new window

Q28975670.accdb
0
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 

Author Comment

by:jirdeaid
ID: 41840631
Thanks a lot.

A thanks for the example.

So, it I replace "<h1>Test<h1> and using the proper CR chars, wuth

<!DOCTYPE html>
<html>
    <head>
        <title>createPushpinFromCanvasHTML</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    </head>
    <body>
        <div id='printoutPanel'></div>
       
        <div id='myMap' style='width: 100vw; height: 100vh;'></div>
        <script type='text/javascript'>
            function loadMapScenario() {
                var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
credentials:                     'Your Bing Maps Key'
                });
                var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(), {
                    icon: createRedArrow(45),
                    anchor: new Microsoft.Maps.Point(12, 12)
                });
                map.entities.push(pushpin);
                function createRedArrow(heading) {
                    var c = document.createElement('canvas');
                    c.width = 24;
                    c.height = 24;
                    var ctx = c.getContext('2d');
                    // Offset the canvas such that we will rotate around the center of our arrow
                    ctx.translate(c.width * 0.5, c.height * 0.5);
                    // Rotate the canvas by the desired heading
                    ctx.rotate(heading * Math.PI / 180);
                    //Return the canvas offset back to it's original position
                    ctx.translate(-c.width * 0.5, -c.height * 0.5);
                    ctx.fillStyle = '#f00';
                    // Draw a path in the shape of an arrow.
                    ctx.beginPath();
                    ctx.moveTo(12, 0);
                    ctx.lineTo(5, 20);
                    ctx.lineTo(12, 15);
                    ctx.lineTo(19, 20);
                    ctx.lineTo(12, 0);
                    ctx.closePath();
                    ctx.fill();
                    ctx.stroke();
                    // Generate the base64 image URL from the canvas.
                    return c.toDataURL();
                }
               
            }
        </script>
        <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?branch=release&callback=loadMapScenario' async defer></script>
    </body>
</html>

will it work?

by
0
 
LVL 34

Expert Comment

by:ste5an
ID: 41840713
Basically, yes. But the question is: Why not storing this as local HTML file and distributing it with your database file?
0
 

Author Comment

by:jirdeaid
ID: 41840751
You are right!

My problem is "theoretically" quite simple:

I want to show some points for which, in my database, I do have GPS coordinates some pushpins, an text that depend on the type of point. Like this:

PointRef     Lat    Lon   Type        Text
r1                 La1   Lo1   Ty1          Txt1
r2                 La2   Lo1   Ty2          Txt2
r3                 La2   Lo1   Ty2          Txt2


So I want to plot in a map, Google Maps or Bing those 3 points. The map is to be shown inside the WebBrowser.

the code I have sent you is exactly the code that microsoft uses as example to use Bing:

http://www.bing.com/api/maps/sdk/mapcontrol/isdk#createPushpinFromCanvas+JS

so it easy for me just to alter it to my specific case, but I can also use Google Maps.

what would be your suggestion?
0
 
LVL 34

Expert Comment

by:ste5an
ID: 41840793
Pretty simple: Inject the data.

Create JavaScript function to take the data as parameter and call it from Access.

Apparently I'm writing an article about it. So when you can wait some days..
0
 

Author Comment

by:jirdeaid
ID: 41840831
Well... I don't know anything about javascript, so it is, right now, beyond my capabilities. However, if your article, is able to provide easy examples, I will follow it immediately! - how can I know about it? (my email?:joao.serras.pereora@ware.pt)

anyway, I am sending you the database with the "new" code that I have sent you, but it does not work: a totally white page is what is shown... I am sure that the error is mine, and if I can't get to a solution I'll ask a new question...

I am closing this page
Q28975670.accdb
0
 

Author Comment

by:jirdeaid
ID: 41840835
THANKS!
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 41885355
This is because IE is the browser called and it has to run a local script in low security mode. It can be a file you open, or it can be dynamic using strMap:

    WebBrowser.Navigate "about:Blank"
    WebBrowser.Document.Write strMap

but still, the script security will kick in and block.

You may have to run the script off a file from a (local) web server to get passed the strict security.

/gustav
0
 

Author Closing Comment

by:jirdeaid
ID: 41890948
thanks for the help!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

617 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